Re: BUG #18212: Functions txid_status() and pg_xact_status() return invalid status of the specified transaction

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Karina Litskevich <litskevichkarina(at)gmail(dot)com>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, kyzevan23(at)mail(dot)ru, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18212: Functions txid_status() and pg_xact_status() return invalid status of the specified transaction
Date: 2024-02-05 13:51:02
Message-ID: CAPpHfdvbBcBOt6NRC401FgzCtn3H51rr+h8aWpNGxjqXRD_Yww@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi!

On Thu, Nov 30, 2023 at 7:30 AM Karina Litskevich
<litskevichkarina(at)gmail(dot)com> wrote:
> On Tue, Nov 28, 2023 at 8:20 AM Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> wrote:
>>
>> I considered bringing this down to a comparison of 32-bit XIDs, but
>> couldn't come up with a clean method. Therefore, using full XID seems
>> to be the right approach. However, it seems like there is an error in
>> the XID comparison condition. There are cases where oldest_xid and
>> now_epoch_next_xid can have the same value. If we skip running
>> txid_current() in the repro in the your previous mail, and directly
>> execute txid_status(3), it would lead to assertion failure.
>
>
> Thank you for your feedback! You're right, I haven't thought about
> this corner case. Fixed in v2.
>
>> Also, I feel the comments could be more straight forward and simple
>> like this:
>>
>> > Convert oldest_xid into a full XID to compare with the given
>> > XID. Alghouth it's guaranteed that the the oldest and newest XIDs
>> > are within the XID wraparound distance, they may have different
>> > epochs.
>
>
> I tried to improve the comment too. Anyway, don't hesitate to change
> it to whatever you like better.

Thank you for your work on the subject.
I've slightly revised the patch (attached). I'm going to push it if
there are no objections.

------
Regards,
Alexander Korotkov

Attachment Content-Type Size
0001-Fix-wrong-logic-in-TransactionIdInRecentPast-v3.patch application/octet-stream 3.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Karina Litskevich 2024-02-05 14:35:12 Re: BUG #18212: Functions txid_status() and pg_xact_status() return invalid status of the specified transaction
Previous Message Christian Maurer 2024-02-05 12:49:46 Re: BUG #18312: libpq: PQsetdbLogin() not thread-safe