Re: In-doubt window - Mailing list pgsql-hackers

From Tom Lane
Subject Re: In-doubt window
Date
Msg-id 3220.1066666724@sss.pgh.pa.us
Whole thread Raw
In response to In-doubt window  ("Jeroen T. Vermeulen" <jtv@xs4all.nl>)
Responses Re: In-doubt window
List pgsql-hackers
"Jeroen T. Vermeulen" <jtv@xs4all.nl> writes:
> Some of you may remember that we discussed libpqxx's higher-level
> support for transactionality.  

> [complicated scheme]

Another way you can look to see if a transaction has completed is to see
if there is still an ExclusiveLock record for it in pg_locks.  For this
you need to know the transaction's internal XID, but you can get that
from the XMAX of the log record it deleted.  In other words:
insert log record;begin;delete log record;<<payload work>>commit;

On reconnect:
log record not present: it committedelse, read XMAX from log recordzero -> failed before the delete :-(not zero -> look
formatch in pg_locksfound -> transaction still in progress, waitnot found -> it aborted
 

This is all pretty messy though.  Seems like it would be a whole lot
easier if the backend exposed ways to (a) obtain your current
transaction number and (b) inquire directly about the commit status of
a transaction.  However, with the present transaction infrastructure
(b) would only work for a limited time window after the original
transaction (until the corresponding clog space got recycled).  So that
might or might not be good enough for your purposes.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Looks like we'll have a beta5 ...
Next
From: Greg Stark
Date:
Subject: Re: Vacuum thoughts