~ack/storm/postgres-explain

Viewing all changes in revision 449.

  • Committer: Free Ekanayaka
  • Date: 2012-06-12 10:12:04 UTC
  • mfrom: (431.2.15 tpc-support)
  • Revision ID: free.ekanayaka@canonical.com-20120612101204-lm52da6x20mc3mgp
Merge tpc-support [f=132485] [r=stub,therve]

This branch adds support for two-phase commits, using the DB API
version 2.0 (only implemented by psycopg2 at the moment). An example
usage is:

xid = Xid(0, "my-txn", "my-branch") # This models a XA-compliant transaction ID
store.begin(xid)
store.execute(...)
store.prepare()
store.commit()

Or using ZStorm, just call zstorm.set_default_tpc("my-store", True) and ZStorm
will automatically use two-phase commit for that store when running
transaction.commit().

In order to transparently use store.commit() and store.rollback(), without
introducing two new ad-hoc APIs (e.g. Store.tpc_commit/Store.tpc_rollback),
the code of the Connection class keeps track of whether we are in two-phase
transaction or in a regular one, and uses the raw connection's DB API
tpc_commit/tpc_rollback or commit/rollback methods accordingly.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: