Re: Finding if old transactions are running... - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Finding if old transactions are running...
Date
Msg-id 1989.1109313060@sss.pgh.pa.us
Whole thread Raw
In response to Re: Finding if old transactions are running...  (jtv@xs4all.nl)
Responses Re: Finding if old transactions are running...  (jtv@xs4all.nl)
List pgsql-hackers
jtv@xs4all.nl writes:
> Tom, I believe you said at the time that I should check pg_stat_activity. 
> My current code polls it for the old backend pid.  But if that is neither
> 100% reliable nor unconditionally available, wouldn't it be better if I
> just queried pg_locks for the transaction's ID?  Would that work for all
> backend versions I can expect to see?

pg_locks certainly seems like a better solution.  Perhaps it didn't
exist when you went with pg_stat_activity?  Can't recall offhand.

Note that you still want to look for your old backend's PID; it seems
impractically expensive to keep track of the current transaction's XID.
(At a minimum that would cost another query per xact...)
        regards, tom lane


pgsql-hackers by date:

Previous
From: jtv@xs4all.nl
Date:
Subject: Re: Finding if old transactions are running...
Next
From: "Marc G. Fournier"
Date:
Subject: Re: 8.0.X and the ARC patent