Re: Race condition in TransactionIdIsInProgress

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>, Konstantin Knizhnik <knizhnik(at)garret(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Race condition in TransactionIdIsInProgress
Date: 2022-06-25 09:18:51
Message-ID: ff23d8ff-ebf6-7baf-f876-8dd7c95daa84@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 24/06/2022 04:43, Andres Freund wrote:
> On 2022-06-23 22:03:27 +0300, Heikki Linnakangas wrote:
>> In summary, I think we should:
>> - commit and backpatch Simon's
>> just_remove_TransactionIdIsKnownCompleted_call.v1.patch
>> - fix pg_xact_status() to check TransactionIdIsInProgress()
>> - in v15, remove TransationIdIsKnownCompleted function altogether
>>
>> I'll try to get around to that in the next few days, unless someone beats me
>> to it.
>
> Makes sense.

This is what I came up with for master. One difference from Simon's
original patch is that I decided to not expose the
TransactionIdIsKnownNotInProgress(), as there are no other callers of it
in core, and it doesn't seem useful to extensions. I inlined it into the
caller instead.

BTW, should we worry about XID wraparound with the cache? Could you have
a backend sit idle for 2^32 transactions, without making any
TransactionIdIsKnownNotInProgress() calls? That's not new with this
patch, though, it could happen with the single-item cache in transam.c, too.

- Heikki

Attachment Content-Type Size
0001-Fix-visibility-check-when-XID-is-committed-in-CLOG-b.patch text/x-patch 7.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2022-06-25 10:10:22 Re: Race condition in TransactionIdIsInProgress
Previous Message Fabien COELHO 2022-06-25 06:24:30 Re: Future Postgres 15 and Clang 15