Re: Replication slot is not able to sync up
Masahiko Sawada <sawada.mshk@gmail.com>
From: Masahiko Sawada <sawada.mshk@gmail.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>,
Suraj Kharage <suraj.kharage@enterprisedb.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-05-27T18:08:23Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Improve log messages and docs for slot synchronization.
- 1546e17f9d06 18.0 landed
- 25505082f0e7 17.6 landed
On Fri, May 23, 2025 at 10:07 PM Amit Kapila <amit.kapila16@gmail.com> wrote: > > In the case presented here, the logical slot is expected to keep > forwarding, and in the consecutive sync cycle, the sync should be > successful. Users using logical decoding APIs should also be aware > that if due for some reason, the logical slot is not moving forward, > the master/publisher node will start accumulating dead rows and WAL, > which can create bigger problems. I've tried this case and am concerned that the slot synchronization using pg_sync_replication_slots() would never succeed while the primary keeps getting write transactions. Even if the user manually consumes changes on the primary, the primary server keeps advancing its XID in the meanwhile. On the standby, we ensure that the TransamVariables->nextXid is beyond the XID of WAL record that it's going to apply so the xmin horizon calculated by GetOldestSafeDecodingTransactionId() ends up always being higher than the slot's catalog_xmin on the primary. We get the log message "could not synchronize replication slot "s" because remote slot precedes local slot" and cleanup the slot on the standby at the end of pg_sync_replication_slots(). Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com