[Zope-dev] Bug in all database adapters?

Shai Berger shai@aristocart.com
Mon, 06 Aug 2001 18:44:06 +0300


Hi,

I think I just found a deep bug that runs through
most, if not all, relational database adapters, and
some other products (notably, session management) too.

These products usually inherit ZRDB.TM, and trust
it for their trnasaction management. The adapters
usually just implement _begin (if they need to start
the transaction explicitly), _abort and _finish.

The problem is that TM handles two-phase-commit quite
badly, or so it seems to me. Since most DAs don't need
to prepare for commits, it ignores tpc_begin (the first
phase), and calls _finish on tpc_finish (the second phase).

Now, since it ignores tpc_begin, TM's authors thought
they can ignore tpc_abort too -- and they did. However,
this is wrong. If an object raises an exception in the
first phase, the only method called for other ones
may be tpc_abort. As a result, database transactions
will be left hanging -- when the Zope transaction ends,
they will be neither committed nor rolled back, and
any locks they acquired will stay in force.

I have seen this in Zope 2.3.2, but as far as I've seen
the changelogs show nothing related in later versions.

Am I missing something?