[Checkins] SVN: gocept.zeoraid/trunk/ Fix for #465834: allow startup with degraded storages. Missing a test.

Christian Theune ct at gocept.com
Tue Nov 17 03:16:18 EST 2009


Log message for revision 105746:
  Fix for #465834: allow startup with degraded storages. Missing a test.
  

Changed:
  U   gocept.zeoraid/trunk/CHANGES.txt
  U   gocept.zeoraid/trunk/doc/OPERATION.txt
  U   gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py

-=-
Modified: gocept.zeoraid/trunk/CHANGES.txt
===================================================================
--- gocept.zeoraid/trunk/CHANGES.txt	2009-11-17 07:52:00 UTC (rev 105745)
+++ gocept.zeoraid/trunk/CHANGES.txt	2009-11-17 08:16:18 UTC (rev 105746)
@@ -5,7 +5,7 @@
 1.0b6 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- #465834: Allow starting up with degraded storages.
 
 
 1.0b5 (2009-11-14)

Modified: gocept.zeoraid/trunk/doc/OPERATION.txt
===================================================================
--- gocept.zeoraid/trunk/doc/OPERATION.txt	2009-11-17 07:52:00 UTC (rev 105745)
+++ gocept.zeoraid/trunk/doc/OPERATION.txt	2009-11-17 08:16:18 UTC (rev 105746)
@@ -27,3 +27,18 @@
 
 The controller script that comes with ZEORaid returns Nagios-compatible exit
 codes and thus the status command can be used directly as a Nagios command.
+
+
+Starting with degraded storages
+===============================
+
+ZEORaid can start with degraded storages, as long as one functioning storage
+is available.
+
+When starting with a degraded storage, make sure that the initialisation code
+of that storage does not block until the storage becomes available. 
+
+For example, ZEO client's ClientStorage will by default block until the ZEO
+server becomes available. In case you want to start without the ZEO server
+being available, you need to configure the option `wait false` into your
+corresponding. zeoclient section.

Modified: gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py
===================================================================
--- gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py	2009-11-17 07:52:00 UTC (rev 105745)
+++ gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py	2009-11-17 08:16:18 UTC (rev 105746)
@@ -121,6 +121,9 @@
         self.zeo = zeo
         self.storages = {}
         self._threads = set()
+        self.storages_optimal = []
+        self.storages_degraded = []
+
         # Temporary files and directories that should be removed at the end of
         # the two-phase commit. The list must only be modified while holding
         # the commit lock.
@@ -166,8 +169,6 @@
         # Set up list of optimal storages
         self.storages_optimal = tids.pop(max(tids))
 
-        # Set up list of degraded storages
-        self.storages_degraded = []
         # Degrade all remaining (non-optimal) storages
         for name in reduce(lambda x, y: x + y, tids.values(), []):
             self._degrade_storage(name)
@@ -658,9 +659,16 @@
 
     def _open_storage(self, name):
         assert name not in self.storages, "Storage %s already opened" % name
-        storage = self.openers[name].open()
-        assert hasattr(storage, 'supportsUndo') and storage.supportsUndo()
-        self.storages[name] = storage
+        try:
+            storage = self.openers[name].open()
+            assert hasattr(storage, 'supportsUndo') and storage.supportsUndo()
+            storage.load('\x00' * 8)
+            self.storages[name] = storage
+        except Exception, e:
+            logger.critical('Could not open storage %s' % name, exc_info=True)
+            # We were trying to open a storage. Even if we fail we can't be
+            # more broke than before, so don't ever fail due to this.
+            self._degrade_storage(name, fail=False)
 
     def _close_storage(self, name):
         if name in self.storages_optimal:



More information about the checkins mailing list