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:

Following a discussion with several of the sqlalchemy integration authors on #plone today we came up with the following hack to implement this:

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).


For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to