On 2008-01-18 13:05, James Henstridge wrote: > On 18/01/2008, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: >> While this would seem desirable, it is not how the Zope TM >> works. >> >> Phase 1 is implemented by doing a vote on the success >> of the transaction. Phase 2 then finishes or aborts the transaction >> depending on the vote. >> >> If something fails in phase 2, there's no guarantee that partial >> commits can be undone. >> >> The .commit()/.rollback() calls on the database interface would >> be implemented in the phase 2 part. >> >> To avoid your scenario, the ZODB would have to detect the conflict >> during phase 1 (ie. the voting phase). > > Looking at the IDataManager API, it looks like it looks like the > correct way to implement two phase commit would be: > > 1. if tpc_begin() is called, note that two-phase commit is being used. > 2. in commit(), simply prepare the transaction if the two-phase commit > flag is set, rather than actually committing. If this fails, the > transaction obviously fails. > 3. make tpc_vote() a no-op. > 4. tpc_finish() commits the prepared transaction > 5. abort() and tpc_abort() roll back the prepared transaction (if one > was prepared).
Agreed, but at least for Zope database adapters, that's not what's implemented (have a look at ZRDB/TM.py). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 18 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 _______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig