Merge lp:~therve/storm/flush-order-673666 into lp:storm

Proposed by Thomas Herve
Status: Needs review
Proposed branch: lp:~therve/storm/flush-order-673666
Merge into: lp:storm
Diff against target: 48 lines (+27/-0)
2 files modified
storm/references.py (+2/-0)
tests/store/base.py (+25/-0)
To merge this branch: bzr merge lp:~therve/storm/flush-order-673666
Reviewer Review Type Date Requested Status
Gustavo Niemeyer Needs Information
Storm Developers Pending
Review via email: mp+40783@code.launchpad.net

Description of the change

The test case was fairly easy to create, and the fix as well. I'm not convinced this is the best fix, but it seems to be reasonable enough.

To post a comment you must log in.
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

[1]

Yeah, this looks quite simple, but it seems to be hiding a bug somewhere else.

The obvious question is why did the pair survive for that long elsewhere, rather than
getting cleaned up when the transaction was flushed?

review: Needs Information
lp:~therve/storm/flush-order-673666 updated
385. By Thomas Herve

Try another approach

Revision history for this message
Thomas Herve (therve) wrote :

I tried something else: I added an unlink on remove flush. I tried to think hard about the consequences:
 * Can a change go undetected because of that?
 * Can we have a leak because remote_info references local_info?

But I've answered no to both questions, unless I'm missing something.

Unmerged revisions

385. By Thomas Herve

Try another approach

384. By Thomas Herve

Add a test, and one possible fix.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storm/references.py'
2--- storm/references.py 2010-06-01 08:33:33 +0000
3+++ storm/references.py 2010-12-11 11:58:13 +0000
4@@ -645,6 +645,8 @@
5 # remote_info)
6 remote_info.event.hook("removed", self._break_on_remote_removed,
7 weakref.ref(local_info))
8+ remote_info.event.hook("flushed", self._break_on_remote_flushed,
9+ local_info)
10 else:
11 remote_has_changed = False
12 for local_column, remote_column in pairs:
13
14=== modified file 'tests/store/base.py'
15--- tests/store/base.py 2010-10-19 13:36:26 +0000
16+++ tests/store/base.py 2010-12-11 11:58:13 +0000
17@@ -3629,6 +3629,31 @@
18 ref1.selfref = None
19 self.assertRaises(OrderLoopError, self.store.flush)
20
21+ def test_reference_set_clean_flush_order(self):
22+ """
23+ When a L{ReferenceSet} target is removed, it doesn't force the removal
24+ of the flush order if this one is not present in the current
25+ transaction.
26+ """
27+ class MyFoo(Foo):
28+ bars = ReferenceSet(Foo.title, Bar.title)
29+
30+ foo = MyFoo()
31+ foo.title = u"Title 40"
32+ self.store.add(foo)
33+ self.store.flush()
34+
35+ bar = Bar()
36+ bar.id = 400
37+ bar.foo_id = 4000
38+ bar.title = u"Title 40"
39+
40+ foo.bars.add(bar)
41+
42+ self.store.commit()
43+ self.store.flush()
44+ self.store.remove(bar)
45+
46 def add_reference_set_bar_400(self):
47 bar = Bar()
48 bar.id = 400

Subscribers

People subscribed via source and target branches

to status/vote changes: