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
=== modified file 'storm/references.py'
--- storm/references.py 2010-06-01 08:33:33 +0000
+++ storm/references.py 2010-12-11 11:58:13 +0000
@@ -645,6 +645,8 @@
645 # remote_info)645 # remote_info)
646 remote_info.event.hook("removed", self._break_on_remote_removed,646 remote_info.event.hook("removed", self._break_on_remote_removed,
647 weakref.ref(local_info))647 weakref.ref(local_info))
648 remote_info.event.hook("flushed", self._break_on_remote_flushed,
649 local_info)
648 else:650 else:
649 remote_has_changed = False651 remote_has_changed = False
650 for local_column, remote_column in pairs:652 for local_column, remote_column in pairs:
651653
=== modified file 'tests/store/base.py'
--- tests/store/base.py 2010-10-19 13:36:26 +0000
+++ tests/store/base.py 2010-12-11 11:58:13 +0000
@@ -3629,6 +3629,31 @@
3629 ref1.selfref = None3629 ref1.selfref = None
3630 self.assertRaises(OrderLoopError, self.store.flush)3630 self.assertRaises(OrderLoopError, self.store.flush)
36313631
3632 def test_reference_set_clean_flush_order(self):
3633 """
3634 When a L{ReferenceSet} target is removed, it doesn't force the removal
3635 of the flush order if this one is not present in the current
3636 transaction.
3637 """
3638 class MyFoo(Foo):
3639 bars = ReferenceSet(Foo.title, Bar.title)
3640
3641 foo = MyFoo()
3642 foo.title = u"Title 40"
3643 self.store.add(foo)
3644 self.store.flush()
3645
3646 bar = Bar()
3647 bar.id = 400
3648 bar.foo_id = 4000
3649 bar.title = u"Title 40"
3650
3651 foo.bars.add(bar)
3652
3653 self.store.commit()
3654 self.store.flush()
3655 self.store.remove(bar)
3656
3632 def add_reference_set_bar_400(self):3657 def add_reference_set_bar_400(self):
3633 bar = Bar()3658 bar = Bar()
3634 bar.id = 4003659 bar.id = 400

Subscribers

People subscribed via source and target branches

to status/vote changes: