]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
mutable: catch and display first error, so code bugs which break all servers get...
authorBrian Warner <warner@lothar.com>
Mon, 1 Jun 2009 21:04:07 +0000 (14:04 -0700)
committerBrian Warner <warner@lothar.com>
Mon, 1 Jun 2009 21:04:07 +0000 (14:04 -0700)
src/allmydata/mutable/common.py
src/allmydata/mutable/publish.py

index 6504909b94c8327644b8e1c66c543acbc121bf7b..869b27d36f1a1ae96eafeebcece0a923a271d0a2 100644 (file)
@@ -33,7 +33,13 @@ class UnrecoverableFileError(Exception):
 
 class NotEnoughServersError(Exception):
     """There were not enough functioning servers available to place shares
-    upon."""
+    upon. This might result from all servers being full or having an error, a
+    local bug which causes all server requests to fail in the same way, or
+    from there being zero servers. The first error received (if any) is
+    stored in my .first_error attribute."""
+    def __init__(self, why, first_error=None):
+        Exception.__init__(self, why, first_error)
+        self.first_error = first_error
 
 class CorruptShareError(Exception):
     def __init__(self, peerid, shnum, reason):
index 34fad3b885befe26f6ea0013f33b0932d4465d29..e446eeaeea339a5715aa5e547816021b492ecf27 100644 (file)
@@ -108,6 +108,7 @@ class Publish:
         num = self._node._client.log("Publish(%s): starting" % prefix)
         self._log_number = num
         self._running = True
+        self._first_write_error = None
 
         self._status = PublishStatus()
         self._status.set_storage_index(self._storage_index)
@@ -382,7 +383,10 @@ class Publish:
         peerlist.sort()
 
         if not peerlist:
-            raise NotEnoughServersError("Ran out of non-bad servers")
+            raise NotEnoughServersError("Ran out of non-bad servers, "
+                                        "first_error=%s" %
+                                        str(self._first_write_error),
+                                        self._first_write_error)
 
         new_assignments = []
         # we then index this peerlist with an integer, because we may have to
@@ -801,6 +805,8 @@ class Publish:
         for shnum in shnums:
             self.outstanding.discard( (peerid, shnum) )
         self.bad_peers.add(peerid)
+        if self._first_write_error is None:
+            self._first_write_error = f
         self.log(format="error while writing shares %(shnums)s to peerid %(peerid)s",
                  shnums=list(shnums), peerid=idlib.shortnodeid_b2a(peerid),
                  failure=f,