How to determine that a TransactionId is really aborted?

From: Eric Ridge <eebbrr(at)gmail(dot)com>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: How to determine that a TransactionId is really aborted?
Date: 2017-10-22 19:23:39
Message-ID: 75FF3934-2F85-4E19-8F9C-B77B08F7DD11@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

When sitting inside an extension, and given an arbitrary TransactionId, how can you determine that it aborted/crashed *and* that no other active transaction thinks it is still running?

I've tried to answer this question myself (against the 9.3 sources), and it seems like it's just:

{
TransactionId oldestXmin = GetOldestXmin (false, false);
TransactionId xid = 42;

if (TransactionIdPrecedes(xid, oldestXmin) &&
!TransactionIdDidCommit(xid) &&
!TransactionIdIsInProgress(xid)) /* not even sure this is necessary? */
{
/* xid is aborted/crashed and no active transaction cares */
}
}

Can anyone confirm or deny that this is correct? I feel like it is correct, but I'm no expert.

Thanks so much for your time!

eric

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2017-10-22 19:50:58 Re: How to determine that a TransactionId is really aborted?
Previous Message Tom Lane 2017-10-22 18:20:44 Re: Useless(?) asymmetry in parse_func.c