Re: [HACKERS] How to determine that a TransactionId is really aborted?

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: [HACKERS] How to determine that a TransactionId is really aborted?
Дата
Msg-id CA+Tgmob9Ox142oDkhro6y+XRV_2ejBPe6OxFC6AiOuiYn__d2w@mail.gmail.com
обсуждение исходный текст
Ответ на [HACKERS] How to determine that a TransactionId is really aborted?  (Eric Ridge <eebbrr@gmail.com>)
Список pgsql-hackers
On Sun, Oct 22, 2017 at 9:23 PM, Eric Ridge <eebbrr@gmail.com> wrote:
> 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.

I think TransactionIdPrecedes(xid, oldestXmin) &&
!TransactionIdDidCommit(xid) is sufficient.  If the transaction ID
precedes oldestXmin, then it's either committed or aborted; no other
state is possible.  If it didn't commit, it aborted, and it is right
to test that using !TransactionIdDidCommit(xid) since commits are
always recorded but aborts are only usually recorded.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Refactor handling of database attributes betweenpg_dump and pg_dumpall
Следующее
От: David Rowley
Дата:
Сообщение: Re: [HACKERS] Removing [Merge]Append nodes which contain a single subpath