Re: Use-after-free in reorderbuffer.c for INSERT ON CONFLICT

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Postgres bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Ethan Mertz <ethan(dot)mertz(at)gmail(dot)com>
Subject: Re: Use-after-free in reorderbuffer.c for INSERT ON CONFLICT
Date: 2025-08-01 10:00:17
Message-ID: CAA4eK1L3T+9Scoi=g=0QjaJP6pLUZh8iDMMY30cgA4GbY_Y_AA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Aug 1, 2025 at 10:22 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Fri, Aug 01, 2025 at 10:03:14AM +0530, Amit Kapila wrote:
> > We still won't be able to capture the latest LSN in case of
> > REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT. IIRC, update_progress_txn
> > is used to keep the client active so that when many changes are
> > skipped, the client doesn't timeout. In this case, it seems okay to
> > use prev_lsn as well.
>
> I am not quite sure to follow your argument here. In the case of a
> REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT change, we would use
> change->lsn, which is in the case of the patch and HEAD the same
> thing: prev_lsn.
>

I mean to say we can use the same change LSN both for
REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM and
REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT. Right now, for
REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM, we switch the change to
specinsert which would have a prior LSN value (say, if confirm/abort
record will have value, 1000, it will be 800 or so) but we should
still use 1000 for update_progress_txn. The update_progress_txn() is
helpful when such an insert is skipped by a plugin (in this case
pgouput) and in that case, we would require the latest LSN processed
by reorder buffer to pass to it. We use it to send a keep_alive to a
client with the last LSN processed.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2025-08-01 11:45:10 Re: Use-after-free in reorderbuffer.c for INSERT ON CONFLICT
Previous Message Tom Lane 2025-08-01 04:53:23 Re: BUG #19000: gist index returns inconsistent result with gist_inet_ops