[ZODB-Dev] RE: [Zope-Annce] ZODB 3.2.4 release candidate 1released

Dieter Maurer dieter at handshake.de
Thu Sep 9 14:38:57 EDT 2004


Tim Peters wrote at 2004-9-8 17:23 -0400:
>[Tim Peters]
>>> ...
>>> I don't know of a scenario in current ZODB wherein catching something
>>> can make a database inconsistent.  I understand there are persistent
>>> rumors that it can happen, but requests for a specific case have gone
>>> unanswered.
>
>[Dieter Maurer]
>> Shane provided one.
>>
>>
>> Here is another trivial one.
>>
>>      obj.persistentAttr1 = 1
>>      ...
>>      # raise an exception here
>>      ...
>>      obj.persistenAttr2 = obj.persitentAttr1
>>
>> This snipped allows to assume an invariant: after any transaction
>> "persistentAttr2 == persistentAttr1".
>
>I'm sorry, but I'm not following this, probably because there are no commits
>in the example.  Where are you assuming they occur?

The commit is assumed in an outer block to be executed
sometime after the shown code.

Raising the exception is assumed not to occur always (but due to
some bug.

Let's cast it into a slightly different picture:

    try:
      try:
	# perform modifications on persistent state
      except ...
        # do something that does not abort the transaction
	# and does not raise an exception
      ...
      commit()
    except:
      abort()
      ...

Should the "perform modifications" result in any exception,
then the exception is likely to leave the state inconsitent.
Catching the exception causes "commit" to be called which
makes the inconsistent state persistent.

-- 
Dieter


More information about the ZODB-Dev mailing list