Rev 3453: (mbp) Just warn about errors deleting obsolete packs in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue May 27 02:32:44 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3453
revision-id:pqm at pqm.ubuntu.com-20080527013230-8qjaju10duxpy3e2
parent: pqm at pqm.ubuntu.com-20080524120232-22xdromy706t0x16
parent: mbp at sourcefrog.net-20080527010557-vqz3rab2v816oybw
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2008-05-27 02:32:30 +0100
message:
  (mbp) Just warn about errors deleting obsolete packs
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
  bzrlib/transport/fakenfs.py    fakenfs.py-20060402223312-0e29c7275aa384dd
    ------------------------------------------------------------
    revno: 3446.2.2
    revision-id:mbp at sourcefrog.net-20080527010557-vqz3rab2v816oybw
    parent: mbp at sourcefrog.net-20080526033459-l015j1314anlr148
    parent: pqm at pqm.ubuntu.com-20080524120232-22xdromy706t0x16
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: nfs-failure
    timestamp: Tue 2008-05-27 11:05:57 +1000
    message:
      merge trunk
    added:
      bzrlib/tests/file_utils.py     file_utils.py-20080506145406-a1h3ydg2lsh2iriy-1
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
      bzrlib/lockable_files.py       control_files.py-20051111201905-bb88546e799d669f
      bzrlib/merge.py                merge.py-20050513021216-953b65a438527106
      bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
      bzrlib/repofmt/weaverepo.py    presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/smart/branch.py         branch.py-20061124031907-mzh3pla28r83r97f-1
      bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
      bzrlib/smart/repository.py     repository.py-20061128022038-vr5wy5bubyb8xttk-1
      bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
      bzrlib/tests/branch_implementations/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
      bzrlib/tests/branch_implementations/test_push.py test_push.py-20070130153159-fhfap8uoifevg30j-1
      bzrlib/tests/repository_implementations/test_has_same_location.py test_has_same_locati-20070807074648-2i2ah82fbe83iys7-1
      bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
      bzrlib/tests/test_http_response.py test_http_response.py-20060628233143-950b2a482a32505d
      bzrlib/tests/test_lockable_files.py test_lockable_files.py-20051225183927-365c7fd99591caf1
      bzrlib/tests/test_merge_core.py test_merge_core.py-20050824132511-eb99b23a0eec641b
      bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
      bzrlib/tests/test_osutils_encodings.py test_osutils_encodin-20061226013130-kkp732tpt3lm91vv-1
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
      bzrlib/tests/test_smart.py     test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
      bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
      bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
      bzrlib/tests/test_workingtree.py testworkingtree.py-20051004024258-b88d0fe8f101d468
      bzrlib/tests/workingtree_implementations/test_basis_inventory.py test_basis_inventory.py-20051218151655-3650468941091309
      bzrlib/tests/workingtree_implementations/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
      bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
      bzrlib/transport/http/response.py _response.py-20060613154423-a2ci7hd4iw5c7fnt-1
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 3446.2.1
    revision-id:mbp at sourcefrog.net-20080526033459-l015j1314anlr148
    parent: pqm at pqm.ubuntu.com-20080521154523-4hv5qe8a9drke2h1
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: nfs-failure
    timestamp: Mon 2008-05-26 13:34:59 +1000
    message:
      Failure to delete an obsolete pack file should not be fatal.
      
      FakeNFSTransportDecorator blocks deletion of .nfs* files.
      
      Split out _clear_obsolete_packs.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
      bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
      bzrlib/transport/fakenfs.py    fakenfs.py-20060402223312-0e29c7275aa384dd
=== modified file 'NEWS'
--- a/NEWS	2008-05-24 11:41:24 +0000
+++ b/NEWS	2008-05-27 01:05:57 +0000
@@ -52,6 +52,11 @@
       attribute '_remote_is_at_least_1_2' attribute errors.
       (Andrew Bennetts, #220806)
 
+    * Failure to delete an obsolete pack file should just give a warning
+      message, not a fatal error.  It may for example fail if the file is still
+      in use by another process.
+      (Martin Pool)
+      
     * Fix MemoryError during large fetches over HTTP by limiting the amount of
       data we try to read per ``recv`` call.  The problem was observed with
       Windows and a proxy, but might affect other environments as well.

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2008-05-22 05:48:22 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2008-05-27 01:05:57 +0000
@@ -1589,10 +1589,8 @@
                 mode=self.repo.bzrdir._get_file_mode())
             # move the baseline forward
             self._packs_at_load = disk_nodes
-            # now clear out the obsolete packs directory
             if clear_obsolete_packs:
-                self.transport.clone('obsolete_packs').delete_multi(
-                    self.transport.list_dir('obsolete_packs'))
+                self._clear_obsolete_packs()
         finally:
             self._unlock_names()
         # synchronise the memory packs list with what we just wrote:
@@ -1624,6 +1622,16 @@
                 self._names[name] = sizes
                 self.get_pack_by_name(name)
 
+    def _clear_obsolete_packs(self):
+        """Delete everything from the obsolete-packs directory.
+        """
+        obsolete_pack_transport = self.transport.clone('obsolete_packs')
+        for filename in obsolete_pack_transport.list_dir('.'):
+            try:
+                obsolete_pack_transport.delete(filename)
+            except (errors.PathError, errors.TransportError), e:
+                warning("couldn't delete obsolete pack, skipping it:\n%s" % (e,))
+
     def _start_write_group(self):
         # Do not permit preparation for writing if we're not in a 'write lock'.
         if not self.repo.is_write_locked():

=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py	2008-04-26 16:34:47 +0000
+++ b/bzrlib/tests/test_repository.py	2008-05-26 03:34:59 +0000
@@ -39,9 +39,13 @@
 from bzrlib.tests import (
     TestCase,
     TestCaseWithTransport,
+    TestSkipped,
     test_knit,
     )
-from bzrlib.transport import get_transport
+from bzrlib.transport import (
+    fakenfs,
+    get_transport,
+    )
 from bzrlib.transport.memory import MemoryServer
 from bzrlib.util import bencode
 from bzrlib import (
@@ -946,6 +950,22 @@
         pack_names = [node[1][0] for node in index.iter_all_entries()]
         self.assertTrue(large_pack_name in pack_names)
 
+    def test_fail_obsolete_deletion(self):
+        # failing to delete obsolete packs is not fatal
+        format = self.get_format()
+        server = fakenfs.FakeNFSServer()
+        server.setUp()
+        self.addCleanup(server.tearDown)
+        transport = get_transport(server.get_url())
+        bzrdir = self.get_format().initialize_on_transport(transport)
+        repo = bzrdir.create_repository()
+        repo_transport = bzrdir.get_repository_transport(None)
+        self.assertTrue(repo_transport.has('obsolete_packs'))
+        # these files are in use by another client and typically can't be deleted
+        repo_transport.put_bytes('obsolete_packs/.nfsblahblah', 'contents')
+        repo._pack_collection._clear_obsolete_packs()
+        self.assertTrue(repo_transport.has('obsolete_packs/.nfsblahblah'))
+
     def test_pack_after_two_commits_packs_everything(self):
         format = self.get_format()
         tree = self.make_branch_and_tree('.', format=format)

=== modified file 'bzrlib/transport/fakenfs.py'
--- a/bzrlib/transport/fakenfs.py	2006-07-28 16:05:23 +0000
+++ b/bzrlib/transport/fakenfs.py	2008-05-26 03:34:59 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2005, 2006, 2008 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,7 +24,10 @@
 
 from stat import S_ISDIR
 
-import bzrlib.errors as errors
+from bzrlib import (
+    errors,
+    urlutils,
+    )
 from bzrlib.transport.decorator import TransportDecorator, DecoratorServer
 
 
@@ -53,6 +56,11 @@
             else:
                 raise
 
+    def delete(self, relpath):
+        if urlutils.basename(relpath).startswith('.nfs'):
+            raise errors.ResourceBusy(self.abspath(relpath))
+        return self._decorated.delete(relpath)
+
 
 class FakeNFSServer(DecoratorServer):
     """Server for the FakeNFSTransportDecorator for testing with."""




More information about the bazaar-commits mailing list