Re: BUG #19760: CLUSTER loses a row the transaction inserted and then updated in a rolled-back subtransaction

From: Zhijie Hou <houzhijie22(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: shihao zhong <zhong950419(at)gmail(dot)com>, Takeshi Ideriha <iderihatakeshi(at)gmail(dot)com>, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>, alpkeles99(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19760: CLUSTER loses a row the transaction inserted and then updated in a rolled-back subtransaction
Date: 2026-10-24 12:57:23
Message-ID: CAFvd2n8oDbwL96nov_bDcLWYHBMQ8cvgDjYWDLK5MWYfkoa3ug@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On Fri, Oct 23, 2026 at 7:42 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Thu, Oct 22, 2026 at 04:53:41PM +0800, Zhijie Hou wrote:
> > +1 to fix that part first. That part of the fix (patch) looks clean to me. It
> > also covers more common cases, which can happen for both user tables and
> > catalogs, while the other part (the complicated, performance-sensitive one) only
> > covers catalog cases IIUC, as user table DML holds locks until transaction end,
> > so concurrent CLUSTER can't touch it in that case.
>
> Please find attached a patch to do this part, for now.
>
> > One idea to improve is to do these expensive checks only when xmin is not equal
> > to xmax. If xmin is still in progress, xmax cannot be aborted, so it's safe to
> > return early in that case. The DELETE test wouldn't regress after this change,
> > since xmin and xmax differ there. The subxact_update test would still regress,
> > but that's likely a rare case.
>
> Yeah, the xmin <> xmax check would make sense here. I'd like to
> suspect that you should be able to make back for most of the
> performance regression of v2 with tweaks like that.
>
> How does the attached look to you?

Thanks for updating the patch, it looks good to me.

Best Regards,
Zhijie Hou

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-10-24 13:00:01 BUG #19794: Assert in btvacuumcleanup() fails when page counted in pages_free twice
Previous Message Dmytro Astapov 2026-10-24 12:07:36 Re: BUG #19725: PostgreSQL 18.6: pg_restore read failure with io_uring, not observed with worker