Re: START_REPLICATION silently truncates an overlong LSN component

From: Jan Nidzwetzki <jan(at)planetscale(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, 'Ayush Tiwari' <ayushtiwari(dot)slg01(at)gmail(dot)com>, ♂π≌26218 <1991230470(at)qq(dot)com>
Cc: pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Subject: Re: START_REPLICATION silently truncates an overlong LSN component
Date: 2026-10-16 13:03:59
Message-ID: 8b1abbd0-7335-4e68-93ec-91cdbbfd9568@planetscale.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Ayush, Hayato,

Thanks for the patches. I looked into them, and both apply cleanly to
master, and check-world passes. So, these changes look good to me.

On 11.09.26 04:35, Hayato Kuroda (Fujitsu) wrote:

>> I wonder if we should make the same change in libpqwalreceiver too.
>
> I feel it should be, see attached. It could be combined with your patch.
> I grepped the source with the keyword "scanf\(.*%X/%08X", and I could
> not find other places where pg_parse_lsn() is usable as-is.

While looking for other places that need the same change, I found that
readTimeLineHistory() in src/backend/access/transam/timeline.c still
parses the switchpoint with sscanf("%X/%08X"). f31d6fbc31d fixed the
frontend copy of this code in pg_rewind, but not the backend one. The
attached 0003 patch converts it the same way and adds a TAP test to
004_timeline_switch.pl, including a case for the trailing characters
that are now rejected. As with the test in 0001, I'm not sure this one
needs to be committed.

In the attached v2 series, your patches are unchanged; I only added the
new 0003.

Best regards,
Jan

--
Jan Nidzwetzki
PlanetScale Postgres Core Team

Attachment Content-Type Size
v2-0001-Use-pg_parse_lsn-for-START_REPLICATION.patch text/plain 2.5 KB
v2-0002-Use-pg_paser_lsn-in-libpqwalreceiver.patch text/plain 1.4 KB
v2-0003-Use-pg_parse_lsn-for-timeline-history-switchpoint.patch text/plain 4.6 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tender Wang 2026-10-16 13:11:03 Re: BUG #19765: Wrong result from a chain of LEFT JOINs since v16
Previous Message Staroverov Ilja 2026-10-16 12:48:55 pg_stat_statements replaces SQL/JSON ON EMPTY / ON ERROR keywords with parameters