]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Accounting crawler: make share deletion conditional (defaulting to False for now...
authorDaira Hopwood <david-sarah@jacaranda.org>
Mon, 27 May 2013 20:40:19 +0000 (21:40 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Fri, 17 Apr 2015 21:31:40 +0000 (22:31 +0100)
Signed-off-by: Daira Hopwood <david-sarah@jacaranda.org>
src/allmydata/storage/accounting_crawler.py
src/allmydata/test/test_storage.py

index 5e8a5d4090b320e103c5b9cf281dee51b4f0b9b2..9a280df29b212728989cb6c4c5e1855ff329784f 100644 (file)
@@ -34,6 +34,7 @@ class AccountingCrawler(ShareCrawler):
     def __init__(self, backend, statefile, leasedb, clock=None):
         ShareCrawler.__init__(self, backend, statefile, clock=clock)
         self._leasedb = leasedb
+        self._enable_share_deletion = False
 
     def process_prefix(self, cycle, prefix, start_slice):
         # Assume that we can list every prefixdir in this prefix quickly.
@@ -113,7 +114,8 @@ class AccountingCrawler(ShareCrawler):
                     (si_s, shnum) = shareid
                     log.msg(format="share SI=%(si_s)s shnum=%(shnum)s unexpectedly disappeared",
                             si_s=si_s, shnum=shnum, level=log.WEIRD)
-                    self._leasedb.remove_deleted_share(si_a2b(si_s), shnum)
+                    if self._enable_share_deletion:
+                        self._leasedb.remove_deleted_share(si_a2b(si_s), shnum)
 
             recovered_sharesets = [set() for st in xrange(len(SHARETYPES))]
 
@@ -148,9 +150,11 @@ class AccountingCrawler(ShareCrawler):
                 d3.addCallbacks(_deleted, _not_deleted)
                 return d3
 
-            # This only includes stable unleased shares (see ticket #1921).
-            unleased_sharemap = self._leasedb.get_unleased_shares_for_prefix(prefix)
-            d2 = for_items(_delete_share, unleased_sharemap)
+            d2 = defer.succeed(None)
+            if self._enable_share_deletion:
+                # This only includes stable unleased shares (see ticket #1921).
+                unleased_sharemap = self._leasedb.get_unleased_shares_for_prefix(prefix)
+                d2.addCallback(lambda ign: for_items(_delete_share, unleased_sharemap))
 
             def _inc_recovered_sharesets(ign):
                 self.increment(rec, "actual-buckets", sum([len(s) for s in recovered_sharesets]))
index 65c876faaf11c563500270abe664375532580b18..38e91f504a1fc08262a25806442871b333f56a1b 100644 (file)
@@ -5067,8 +5067,13 @@ class AccountingCrawlerTest(CrawlerTestMixin, WebRenderingMixin, ReallyEqualMixi
         self.failUnlessEqual((len(aa.get_leases(si)), len(sa.get_leases(si))),
                              expected)
 
+    def _skip_if_share_deletion_is_disabled(self, server):
+        if not server.get_accounting_crawler()._enable_share_deletion:
+            raise unittest.SkipTest("share deletion by the accounting crawler is disabled")
+
     def test_expire_age(self):
         server = self.create("test_expire_age", detached=True)
+        self._skip_if_share_deletion_is_disabled(server)
 
         # setting expiration_time to 2000 means that any lease which is more
         # than 2000s old will be expired.
@@ -5188,6 +5193,7 @@ class AccountingCrawlerTest(CrawlerTestMixin, WebRenderingMixin, ReallyEqualMixi
 
     def test_expire_cutoff_date(self):
         server = self.create("test_expire_cutoff_date", detached=True)
+        self._skip_if_share_deletion_is_disabled(server)
 
         # setting cutoff-date to 2000 seconds ago means that any lease which
         # is more than 2000s old will be expired.