[ZODB-Dev] Supporting a DataManager without Two Phase Commit

Laurence Rowe l at lrowe.co.uk
Fri May 4 17:33:05 EDT 2007


Hi,

Several people have made SQLalchemy integrations recently. SQLAlchemy 
does not support Two Phase Commit (2PC) so correctly tying it in with 
zope's transactions is tricky. With multiple One Phase Commit (1PC) 
DataManagers the problem is of course intractable, but given the 
popularity of mappers like SQLAlchemy I think Zope should support a 
single 1PC DataManager.

This websphere document describes a method to integrate a single 1PC 
resource with 2PC resources:
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/lao/tasks/tla_ep.html

Following a discussion with several of the sqlalchemy integration 
authors on #plone today we came up with the following hack to implement 
this:
http://dev.plone.org/collective/browser/collective.lead/trunk/collective/lead/tx.py

The DataManager is given a high sortKey to ensure that it is considered 
last, and commits in tpc_vote, before the other (2PC) DataManagers' 
tpc_finish methods are called.

The hack obviously relies on only one DataManager making use of the 
trick. It would be nice to make this was supported directly so that an a 
  error could be thrown when more than one 1PC DataManager joined a 
transaction.

This could be implemented by changing the signature of 
transaction._transaction.Transaction.join to have an optional 
single_phase argument (default would be False). The 1PC resource would 
then be registered seperately to the 2PC resources and _commitResources 
would call commit on the 1PC resource between tpc_vote and tpc_finish.

If you think this would be helpful I'll try and supply a patch (need to 
look into the detail of how failed transactions are cleaned up).

Laurence



More information about the ZODB-Dev mailing list