Merge lp:~jameinel/bzr/2.0.4-495000-win32-autopack into lp:bzr/2.0

Proposed by John A Meinel
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jameinel/bzr/2.0.4-495000-win32-autopack
Merge into: lp:bzr/2.0
Diff against target: 75 lines (+42/-1)
3 files modified
NEWS (+4/-0)
bzrlib/repofmt/groupcompress_repo.py (+2/-1)
bzrlib/tests/per_pack_repository.py (+36/-0)
To merge this branch: bzr merge lp:~jameinel/bzr/2.0.4-495000-win32-autopack
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+16264@code.launchpad.net
To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

This fixes bug #495000. The 2a format Packer code wasn't passing the 'reload_func' to the rest of the code, so if an autopack wanted to restart, reload_func() wasn't getting called properly.

The test is a bit brittle, but probably good enough, especially given the one-line fix.

Revision history for this message
John A Meinel (jameinel) wrote :

It seems I forgot to 'bzr push' after writing the test before I submitted. There is one now. (well, once lp refreshes the diff.)

Revision history for this message
Martin Pool (mbp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2009-12-18 22:03:09 +0000
3+++ NEWS 2009-12-21 16:48:15 +0000
4@@ -31,6 +31,10 @@
5 This will likely have an impact on any other process that is serving for
6 an extended period of time. (John Arbash Meinel, #494406)
7
8+* The 2a format wasn't properly restarting autopacks when something
9+ changed underneath it (like another autopack). Now concurrent
10+ autopackers will properly succeed. (John Arbash Meinel, #495000)
11+
12 Improvements
13 ************
14
15
16=== modified file 'bzrlib/repofmt/groupcompress_repo.py'
17--- bzrlib/repofmt/groupcompress_repo.py 2009-09-24 20:03:43 +0000
18+++ bzrlib/repofmt/groupcompress_repo.py 2009-12-21 16:48:15 +0000
19@@ -352,7 +352,8 @@
20 """Build a VersionedFiles instance on top of this group of packs."""
21 index_name = index_name + '_index'
22 index_to_pack = {}
23- access = knit._DirectPackAccess(index_to_pack)
24+ access = knit._DirectPackAccess(index_to_pack,
25+ reload_func=self._reload_func)
26 if for_write:
27 # Use new_pack
28 if self.new_pack is None:
29
30=== modified file 'bzrlib/tests/per_pack_repository.py'
31--- bzrlib/tests/per_pack_repository.py 2009-09-07 03:00:23 +0000
32+++ bzrlib/tests/per_pack_repository.py 2009-12-21 16:48:15 +0000
33@@ -546,6 +546,42 @@
34 finally:
35 tree.unlock()
36
37+ def test_concurrent_pack_during_autopack(self):
38+ tree = self.make_branch_and_tree('tree')
39+ tree.lock_write()
40+ try:
41+ for i in xrange(9):
42+ tree.commit('rev %d' % (i,))
43+ r2 = repository.Repository.open('tree')
44+ r2.lock_write()
45+ try:
46+ # Monkey patch so that pack occurs while the other repo is
47+ # autopacking. This is slightly bad, but all current pack
48+ # repository implementations have a _pack_collection, and we
49+ # test that it gets triggered. So if a future format changes
50+ # things, the test will fail rather than succeed accidentally.
51+ autopack_count = [0]
52+ r1 = tree.branch.repository
53+ orig = r1._pack_collection.pack_distribution
54+ def trigger_during_auto(*args, **kwargs):
55+ ret = orig(*args, **kwargs)
56+ if not autopack_count[0]:
57+ r2.pack()
58+ autopack_count[0] += 1
59+ return ret
60+ r1._pack_collection.pack_distribution = trigger_during_auto
61+ tree.commit('autopack-rev')
62+ # This triggers 2 autopacks. The first one causes r2.pack() to
63+ # fire, but r2 doesn't see the new pack file yet. The
64+ # autopack restarts and sees there are 2 files and there
65+ # should be only 1 for 10 commits. So it goes ahead and
66+ # finishes autopacking.
67+ self.assertEqual([2], autopack_count)
68+ finally:
69+ r2.unlock()
70+ finally:
71+ tree.unlock()
72+
73 def test_lock_write_does_not_physically_lock(self):
74 repo = self.make_repository('.', format=self.get_format())
75 repo.lock_write()

Subscribers

People subscribed via source and target branches