pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ♂π≌26218 <1991230470@qq.com>
To: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Subject: START_REPLICATION silently truncates an overlong LSN component
Date: Tue, 8 Sep 2026 17:58:13 +0800
Message-ID: <tencent_C6ED19DF1759CDD37E786F7EE0B5207D0009@qq.com> (raw)

Hi, I found a potential bug in PostgreSQL's replication command parser where `START_REPLICATION` accepts an LSN whose high component contains more than eight hexadecimal digits and silently truncates it to a different WAL location, rather than rejecting it. Description: The replication command `START_REPLICATION` accepts an LSN in the format `X/Y`, where `X` and `Y` are hexadecimal numbers. The parser accepts an overlong high component (e.g., `123456789/0`) and silently maps it to `23456789/00000000` by truncating the excess digit. This means the server starts replication from a different WAL location than the user requested, without any error or warning. PostgreSQL version: - PostgreSQL 19beta3 (Docker-based runtime) - Source commit: not recorded in the original report - Build relationship: the tested image was not an exact-HEAD build Environment: - Docker-based PostgreSQL 19beta3 runtime - Replication connection privileges required - No special server configuration beyond standard replication setup Steps to Reproduce: Run the following command using a replication connection: ```bash psql "user=postgres dbname=postgres replication=database" \   -c 'START_REPLICATION 123456789/0;'


Then inspect the PostgreSQL server log. For a filing-quality rerun, enable log_error_verbosity=verbose and capture the complete relevant log section.

Actual Result:

The server log identifies a different starting point. For the command above, the log shows:
text



requested starting point 23456789/00000000 ... STATEMENT: START_REPLICATION 123456789/0;


The original 123456789/0 was interpreted as 23456789/00000000, with the high component truncated from nine digits to eight.

Expected Result:

The backend should reject an LSN component longer than eight hexadecimal digits with a syntax error or a specific "invalid LSN" error. It should not silently convert it to another WAL location.

Reproduction Frequency:


Positive reproduction: 2/2 on PostgreSQL 19beta3



Negative control: START_REPLICATION 0/0 remained 0/0


Additional Observations:

The issue likely originates from the replication scanner accepting an unrestricted hexadecimal token and parsing it into a 32-bit destination without checking the component width or whether the conversion was lossless. This could lead to replication starting from an unexpected LSN, potentially causing data inconsistencies or confusion during recovery.

I searched the public PostgreSQL bug archives and did not find any report specifically addressing LSN component overflow or truncation in START_REPLICATION. Please confirm whether this is considered a bug.




♂π≌26218
1991230470@qq.com

view thread (20+ messages)  latest in thread

Message-ID: <tencent_C6ED19DF1759CDD37E786F7EE0B5207D0009@qq.com>
Permalink:  ../tencent_C6ED19DF1759CDD37E786F7EE0B5207D0009@qq.com/
Also on:    postgresql.org/message-id/tencent_C6ED19DF1759CDD37E786F7EE0B5207D0009@qq.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: 1991230470@qq.com
  Subject: Re: START_REPLICATION silently truncates an overlong LSN component
  In-Reply-To: <tencent_C6ED19DF1759CDD37E786F7EE0B5207D0009@qq.com>
  References: <tencent_C6ED19DF1759CDD37E786F7EE0B5207D0009@qq.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox