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-02 03:27:10
Message-ID: CAA4eK1JOk2u=co1VHRbxH6D=dXCcxTtJosR2qyvhCiL9qgOXBw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Aug 1, 2025 at 5:15 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Fri, Aug 01, 2025 at 03:30:17PM +0530, Amit Kapila wrote:
> > 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.
>
> Ah, OK, I've missed your point then. It's kind of an optimization in
> itself because we would be a bit more aggressive with the updates, but
> I agree to do that in the scope of this fix. The updated attached
> uses prev_lsn for the job, for both the ABORT and CONFIRM cases,
> meaning a one-liner.
>

The proposed change looks good to me.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Xuneng Zhou 2025-08-02 04:28:05 Re: Unexpected Standby Shutdown on sync_replication_slots change
Previous Message Peter Geoghegan 2025-08-02 03:07:31 Re: Postgres: Queries are too slow after upgrading to PG17 from PG15