Re: Replication slot is not able to sync up - Mailing list pgsql-hackers

From Masahiko Sawada
Subject Re: Replication slot is not able to sync up
Date
Msg-id CAD21AoBXiR5axPo7Jddyj1Q-9JFxwVLiu9x7yhgkLK+urVHZPQ@mail.gmail.com
Whole thread Raw
In response to Re: Replication slot is not able to sync up  (Amit Kapila <amit.kapila16@gmail.com>)
Responses RE: Replication slot is not able to sync up
RE: Replication slot is not able to sync up
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Dmitry Dolgov
Date:
Subject: Re: Automatically sizing the IO worker pool
Next
From: Aleksander Alekseev
Date:
Subject: Doc: section "8.21. Pseudo-Types" needs a bit of clarification?