[Checkins] SVN: gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py - made starting storage recovery atomic
Thomas Lotze
tl at gocept.com
Mon Sep 27 07:46:50 EDT 2010
Log message for revision 116979:
- made starting storage recovery atomic
- keep tests from printing exceptions by solving thread ordering problems
Changed:
U gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py
-=-
Modified: gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py
===================================================================
--- gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py 2010-09-27 10:47:21 UTC (rev 116978)
+++ gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py 2010-09-27 11:46:50 UTC (rev 116979)
@@ -182,6 +182,11 @@
def close(self):
"""Close the storage."""
+ for thread in self._threads:
+ # We give all the threads a chance to get done quickly.
+ # This is mostly a convenience for the tests to not annoy.
+ thread.join(5)
+
if self.closed:
# Storage may be closed more than once, e.g. by tear-down methods
# of tests.
@@ -613,12 +618,24 @@
@ensure_open_storage
def raid_recover(self, name):
- if name not in self.storages_degraded:
- return
+ self._write_lock.acquire()
+ try:
+ if self.storage_recovering is not None:
+ return
+ if name not in self.storages_degraded:
+ return
+
+ self.storages_degraded.remove(name)
+ del self.degrade_reasons[name]
+ self.storage_recovering = name
+ finally:
+ self._write_lock.release()
+
t = threading.Thread(target=self._recover_impl, args=(name,))
self._threads.add(t)
t.setDaemon(True)
t.start()
+
return 'recovering %r' % (name,)
@ensure_open_storage
@@ -874,9 +891,6 @@
raise gocept.zeoraid.interfaces.RAIDError("RAID storage is failed.")
def _recover_impl(self, name):
- self.storages_degraded.remove(name)
- del self.degrade_reasons[name]
- self.storage_recovering = name
try:
target = self.openers[name].open()
except Exception:
More information about the checkins
mailing list