Re: Fix concurrent-abort detection for subtransactions of prepared transactions

From: Vaijayanti Bharadwaj <vaijayanti(dot)bharadwaj(at)enterprisedb(dot)com>
To: Rahila Syed <rahilasyed90(at)gmail(dot)com>
Cc: pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Subject: Re: Fix concurrent-abort detection for subtransactions of prepared transactions
Date: 2026-10-27 16:54:27
Message-ID: CAFNcJWUoQ1ouC3=RCfS4aX7Bwwf5LmkjYffLX8kWDWWDiHARuw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Rahila,

Thanks for the review. You are right on both the points.

1. I separated the code change and the test into two patches. The code
change needs the fix backported up to PG 14. And the test to PG 17 since it
uses injection points.
2. I made the change to use `txn` directly: rbtxn_is_prepared(txn)

I have attached the updated patches.

Thanks,
Vaijayanti

On Tue, Oct 27, 2026 at 8:29 PM Rahila Syed <rahilasyed90(at)gmail(dot)com> wrote:

> Hi Vaijayanti,
>
> Thank you for reporting this bug. I verified that the patch indeed
> fixes the problem.
>
> Please see a couple of comments below:
>
> 1. The commit that introduced the underlying code is a271a1b50e9, which was
> released with PG14; however, the patch mentions backporting the fix up
> to PG15. Is this
> intentional?
>
> >
> > if (streaming || rbtxn_is_prepared(rbtxn_get_toptxn(change->txn)))
> >
> > Once the transaction is prepared, its subtransactions commit or abort
> together with it. The error handler already tests rbtxn_is_prepared(txn) on
> the top-level transaction, so it needs no change.
>
> 2. A nitpick: Should the check be replaced by rbtxn_is_prepared(txn)
> instead of the rbxtn_get_toptxn(change->txn). The `txn` in
> `ReorderBufferProcessTXN` is a top level transaction and this function
> calls the exact same check further below which would make it
> consistent.
>
> Apart from that, the changes look good to me.
>
> Adding Amit Kapila to CC since he is the author of the original commit.
>
> Thank you,
> Rahila Syed
>

Attachment Content-Type Size
v2-0001-Fix-concurrent-abort-detection-for-subtransaction.patch application/octet-stream 1.9 KB
v2-0002-Add-test-for-concurrent-abort-of-a-prepared-trans.patch application/octet-stream 7.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2026-10-27 17:09:16 Re: First draft of PG 19 release notes
Previous Message Greg Burd 2026-10-27 16:50:00 Re: nbtree: opt-in leaf key prefix compression