Merge lp:~facundo/ubuntuone-client/fix-getdelta-repetition into lp:ubuntuone-client

Proposed by Facundo Batista
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 1242
Merged at revision: 1245
Proposed branch: lp:~facundo/ubuntuone-client/fix-getdelta-repetition
Merge into: lp:ubuntuone-client
Diff against target: 36 lines (+15/-0)
2 files modified
tests/syncdaemon/test_action_queue.py (+9/-0)
ubuntuone/syncdaemon/action_queue.py (+6/-0)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/fix-getdelta-repetition
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Curtis Caravone (community) Approve
Review via email: mp+105220@code.launchpad.net

Commit message

Use PathLockTree to get one GetDelta at a time (LP: #883252).

Description of the change

Use PathLockTree to get one GetDelta at a time.

Actually, two are sent at the same time, but not a zillion as today.

This works with GetDelta rules (don't issue another GetDelta if there's another one with same or less gen number *not running*). The not running part is the trick, so this will happen for a zillion GetDeltas with the same gen number (common case after a move and a lot of operations):

- First GD is queued, and run.

- Second GD is queued (as first is running), but gets locked in the PathLockTree.

- Third and subsequent GDs are not queued, as there's one not running for that gen number.

Test included.

To post a comment you must log in.
Revision history for this message
Curtis Caravone (caravone) :
review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_action_queue.py'
2--- tests/syncdaemon/test_action_queue.py 2012-04-19 17:24:57 +0000
3+++ tests/syncdaemon/test_action_queue.py 2012-05-09 15:05:24 +0000
4@@ -4478,6 +4478,15 @@
5 cmd = GetDelta(self.rq, 'vol', 1)
6 self.assertEqual(cmd.uniqueness, ('GetDelta', 'vol'))
7
8+ def test_path_locking(self):
9+ """Test that it acquires correctly the path lock."""
10+ t = []
11+ self.patch(PathLockingTree, 'acquire',
12+ lambda s, *a, **k: t.extend((a, k)))
13+ cmd = GetDelta(self.rq, 'volume_id', 123)
14+ cmd._acquire_pathlock()
15+ self.assertEqual(t, [('GetDelta', 'volume_id'), {'logger': None}])
16+
17
18 class GetDeltaFromScratchTestCase(ConnectedBaseTestCase):
19 """Test for GetDelta ActionQueueCommand."""
20
21=== modified file 'ubuntuone/syncdaemon/action_queue.py'
22--- ubuntuone/syncdaemon/action_queue.py 2012-04-19 17:24:57 +0000
23+++ ubuntuone/syncdaemon/action_queue.py 2012-05-09 15:05:24 +0000
24@@ -2070,6 +2070,12 @@
25 self.log = mklog(logger, 'GetDelta', self.volume_id,
26 None, generation=self.generation)
27
28+ def _acquire_pathlock(self):
29+ """Acquire pathlock."""
30+ pathlock = self.action_queue.pathlock
31+ return pathlock.acquire('GetDelta', str(self.volume_id),
32+ logger=self.log)
33+
34
35 class GetDeltaFromScratch(ActionQueueCommand):
36 """Get a delta from scratch."""

Subscribers

People subscribed via source and target branches