[ZODB-Dev] conflict resolution + packing = lost objects ????
Toby Dickenson
tdickenson@geminidataloggers.com
Fri, 10 May 2002 09:10:31 +0100
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.
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?