[DB-SIG] Two-phase commit API proposal (was Re: Any standard for two phase commit APIs?)

James Henstridge james at jamesh.id.au
Mon Jan 21 13:36:25 CET 2008


On 21/01/2008, M.-A. Lemburg <mal at egenix.com> wrote:
> Sorry, I wasn't clear enough:
>
> If a connection fails and the transaction XID persists, how do you:
>
>  * identify which XIDs are still pending (xa_recover)
>
>  * tell the RM to drop all resources associacted with an XID
>    (xa_forget)
>
> once the TM has reconnected. These APIs appear to be needed
> in order for the TM to be able to cleanup the RM after e.g.
> a lost connection.
>
> OTOH, perhaps just doing a rollback with the known XID and
> ignoring any errors would do the same without the need for
> extra APIs.

There is nothing in the proposal I sent about recovery as I considered
it out of scope for the initial API.  Given the interest, it is
probably worth adding.

Finding out about outstanding transactions could be done with a
Connection.xa_recover() method that returns a list of transaction IDs.
 In PostgreSQL this can be implemented with "SELECT gid from
pg_prepared_xacts".  For MySQL it can be implemented with "XA
RECOVER".  I don't know about others.

For the xa_forget() call, does it differ from rolling back a prepared
transaction?

James.


More information about the DB-SIG mailing list