[DB-SIG] Any standard for two phase commit APIs?

Stuart Bishop stuart at stuartbishop.net
Fri Jan 18 14:07:24 CET 2008


James Henstridge wrote:

> So is there any recommendations for what a two-phase commit API should
> look like?

Here are the three obvious possibilities. The first is what you already
have. The other two also allow access to all of PostgreSQL's two phase
commit API and are functionally identical. All would work fine for
integrating with the transaction managers I'm familiar with (Z2, Z3, Storm).
The difference is just spelling. Any opinions?


conn = connect([...])
[... do work ...]
try:
    xid = conn.prepare_transaction('xid%f' % random())
    [... prepare other participants ...]
except:
    conn.rollback_prepared(xid)
else:
    conn.commit_prepared(xid)



conn = connect([...])
[... do work ...]
try:
    trans = conn.prepare_transaction('xid%f' % random())
    [... prepare other participants ...]
except:
    trans.rollback()
else:
    trans.commit()



conn = connect([...])
[... do work ...]
try:
    trans = PreparedTransaction(con, 'xid%f' % random())
    [... prepare other participants ...]
except:
    trans.rollback()
else:
    trans.commit()

-- 
Stuart Bishop <stuart at stuartbishop.net>
http://www.stuartbishop.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://mail.python.org/pipermail/db-sig/attachments/20080118/ccb4b04a/attachment.pgp 


More information about the DB-SIG mailing list