[Checkins] SVN: gocept.zeoraid/trunk/src/gocept/zeoraid/ checkpoint, recovery is broken and debugging stuff is left in the code

Thomas Lotze tl at gocept.com
Thu Jan 8 09:59:28 EST 2009


Log message for revision 94623:
  checkpoint, recovery is broken and debugging stuff is left in the code

Changed:
  U   gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py
  U   gocept.zeoraid/trunk/src/gocept/zeoraid/tests/test_basics.py

-=-
Modified: gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py
===================================================================
--- gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py	2009-01-08 14:43:37 UTC (rev 94622)
+++ gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py	2009-01-08 14:59:27 UTC (rev 94623)
@@ -110,12 +110,6 @@
     # we bring them back into the pool of optimal storages.
     _db = None
 
-    # The last transaction that we know of. This is used to keep a global
-    # knowledge of the current assumed state and verify storages that might
-    # have fallen out of sync. It is also used as a point of reference
-    # for generating new TIDs.
-    _last_tid = None
-
     # Timeout for threaded/parallel operations on backend storages.
     timeout = 60
 
@@ -163,6 +157,7 @@
                 continue
             tids.setdefault(tid, [])
             tids[tid].append(name)
+        print tids
 
         if not tids:
             # No storage is working.
@@ -170,8 +165,7 @@
                 "Can't start without at least one working storage.")
 
         # Set up list of optimal storages
-        self._last_tid = max(tids)
-        self.storages_optimal = tids.pop(self._last_tid)
+        self.storages_optimal = tids.pop(max(tids))
 
         # Set up list of degraded storages
         self.storages_degraded = []
@@ -227,7 +221,7 @@
         """Return the id of the last committed transaction."""
         if self.raid_status() == 'failed':
             raise gocept.zeoraid.interfaces.RAIDError('RAID is failed.')
-        return self._last_tid
+        return self._apply_all_storages('lastTransaction')
 
     def __len__(self):
         """The approximate number of objects in the storage."""
@@ -351,7 +345,7 @@
 
             if tid is None:
                 # No TID was given, so we create a new one.
-                tid = self._new_tid(self._last_tid)
+                tid = self._new_tid(self.lastTransaction())
             self._tid = tid
 
             self._apply_all_storages('tpc_begin',
@@ -376,7 +370,6 @@
                     # ClientStorage contradict each other and the documentation
                     # is non-existent. We trust ClientStorage here.
                     callback(self._tid)
-                self._last_tid = self._tid
                 return self._tid
             finally:
                 self._transaction = None
@@ -740,7 +733,7 @@
             t.start()
 
         # Wait for threads to finish and pick up results.
-        results = []
+        results = {}
         exceptions = []
         for thread in threads:
             # XXX The timeout should be calculated such that the total time
@@ -754,7 +747,7 @@
             if thread.exception:
                 exceptions.append(thread.exception)
             elif thread.reliable:
-                results.append(thread.result)
+                results[thread.storage_name] = thread.result
 
         # Analyse result consistency.
         consistent = True
@@ -765,12 +758,13 @@
             # must be consistent anyway.
             pass
         elif results:
-            ref = results[0]
-            for test in results:
+            ref = results.values()[0]
+            for test in results.values():
                 if test != ref:
                     consistent = False
                     break
         if not consistent:
+            import pdb; pdb.set_trace() 
             self.close()
             raise gocept.zeoraid.interfaces.RAIDError(
                 "RAID is inconsistent and was closed.")
@@ -779,7 +773,7 @@
         if exceptions:
             raise exceptions[0]
         if results:
-            return results[0]
+            return results.values()[0]
 
         # We did not get any reliable result, making this call effectively a
         # no-op.

Modified: gocept.zeoraid/trunk/src/gocept/zeoraid/tests/test_basics.py
===================================================================
--- gocept.zeoraid/trunk/src/gocept/zeoraid/tests/test_basics.py	2009-01-08 14:43:37 UTC (rev 94622)
+++ gocept.zeoraid/trunk/src/gocept/zeoraid/tests/test_basics.py	2009-01-08 14:59:27 UTC (rev 94623)
@@ -49,9 +49,9 @@
 import ZODB.config
 
 # Uncomment this to get helpful logging from the ZEO servers on the console
-#import logging
-#logging.getLogger().addHandler(logging.StreamHandler())
-#logging.getLogger().setLevel(0)
+import logging
+logging.getLogger().addHandler(logging.StreamHandler())
+logging.getLogger().setLevel(0)
 
 
 def fail(obj, name):
@@ -235,6 +235,7 @@
 class FailingStorageTestBase(object):
 
     def _disable_storage(self, index):
+        print self._storage.storages_optimal[index]
         self._storage.raid_disable(self._storage.storages_optimal[index])
 
     def test_apply_storage_disconnect(self):
@@ -1230,6 +1231,9 @@
             self, self._backend(0), self._backend(1))
         self._storage.new_oid()
         self.assertEquals('optimal', self._storage.raid_status())
+        # Make sure we can still write to the RAID.
+        self._dostore()
+        self.assertEquals('optimal', self._storage.raid_status())
 
     def test_timeoutBackend(self):
         self._storage.timeout = 2



More information about the Checkins mailing list