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

James.
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to