[ZODB-Dev] conflict resolution + packing = lost objects ????
Jim Fulton
jim@zope.com
Fri, 10 May 2002 06:24:25 -0400
Toby Dickenson wrote:
>
> I think the following scenario, which combines conflict resolution with
> packing, can cause all revisions of an object to be removed from the
> persistent database while there is still a live reference to it...
>
> 1. There are two objects A and B. A has the only reference to B.
>
> 2. There are two threads X and Y. both of them have just started a
> transaction, and have touched objects A and B so they are both loaded into
> memory.
>
> 3. In thread X: A's reference to B is removed. The transaction commits, and
> A's new state is stored. At this point there are no references to B except in
> historical revisions of A.
>
> 4. In thread Y: A is modified, but it still has a reference to B. The
> transaction commits. When A's new state is written, the storage will detect
> that its serial number is not the most recent revision, therefore it invokes
> conflict resolution. The post-conflict-resolution state of object A contains
> a reference to B.
One could argue that this conflict resolution is bogus, since the
resolution effectively forgot the change made by X.
> If the database was packed between step 3 and 4 such that all historical
> revisions of A were removed, all revisions of B would also be removed. This
> leaves a dangling reference to B once the post-conflict-resolution state of A
> is stored in 4.
>
> I dont see any reason why this cant happen in theory, but so far I have not
> observed it in practice. Am I missing something?
No, you aren't. A similar scenario occurs if an application deletes B,
but hold a reference to it and, in a later transaction, puts it back.
This scenario is pretty unlikely with packing. It's not so unlikely
with a reference-counting approach as is used in the Packless storage.
One way to avoid this would be to prevent committing transactions with
dangling references.
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org