pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Don't persist synced slots before a consistent snapshot is built 2+ messages / 1 participants [nested] [flat]
* pgsql: Don't persist synced slots before a consistent snapshot is built @ 2026-11-19 03:13 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Amit Kapila @ 2026-11-19 03:13 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Don't persist synced slots before a consistent snapshot is built. update_local_synced_slot() tries to advance the local slot only when the remote slot's LSN or catalog_xmin is ahead of it. If no consistent snapshot can be built from restart_lsn, SS_SKIP_NO_CONSISTENT_SNAPSHOT is set so the slot stays temporary. But the advance attempt has already moved the local confirmed_flush to the remote value. In the next cycle, if the remote slot has not advanced, the advance check is skipped and the skip reason is reset to SS_SKIP_NONE. Since 788ec96d59, update_and_persist_local_synced_slot() decides on persistence from slotsync_skip_reason, so it persists the slot and marks it sync-ready before a consistent snapshot exists. After promotion, such a slot can start decoding at a consistent point later than its confirmed_flush, silently skipping transactions that committed in between and were never sent to the subscriber. It can also trigger an assertion failure in later sync cycles. Fix this by tracking, across update_local_synced_slot(), whether the current cycle reached a consistent snapshot, and setting SS_SKIP_NO_CONSISTENT_SNAPSHOT whenever a temporary slot has not reached one. Reported-by: Masahiko Sawada <sawada.mshk@gmail.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Reviewed-by: João Rito <joaovictor.rito@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/CAD21AoDdn9QJ2Q5dNkW9dAAzvoH-9yEF7jw64QpHJGqi3YJMvQ@mail.gmail.com Backpatch-through: 19 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/ba11c48390004ed49b889cbd718c9e5f691fe493 Modified Files -------------- src/backend/replication/logical/slotsync.c | 53 ++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 18 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Don't persist synced slots before a consistent snapshot is built @ 2026-11-19 03:13 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Amit Kapila @ 2026-11-19 03:13 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Don't persist synced slots before a consistent snapshot is built. update_local_synced_slot() tries to advance the local slot only when the remote slot's LSN or catalog_xmin is ahead of it. If no consistent snapshot can be built from restart_lsn, SS_SKIP_NO_CONSISTENT_SNAPSHOT is set so the slot stays temporary. But the advance attempt has already moved the local confirmed_flush to the remote value. In the next cycle, if the remote slot has not advanced, the advance check is skipped and the skip reason is reset to SS_SKIP_NONE. Since 788ec96d59, update_and_persist_local_synced_slot() decides on persistence from slotsync_skip_reason, so it persists the slot and marks it sync-ready before a consistent snapshot exists. After promotion, such a slot can start decoding at a consistent point later than its confirmed_flush, silently skipping transactions that committed in between and were never sent to the subscriber. It can also trigger an assertion failure in later sync cycles. Fix this by tracking, across update_local_synced_slot(), whether the current cycle reached a consistent snapshot, and setting SS_SKIP_NO_CONSISTENT_SNAPSHOT whenever a temporary slot has not reached one. Reported-by: Masahiko Sawada <sawada.mshk@gmail.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Reviewed-by: João Rito <joaovictor.rito@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/CAD21AoDdn9QJ2Q5dNkW9dAAzvoH-9yEF7jw64QpHJGqi3YJMvQ@mail.gmail.com Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f66932c8dd42429afb63352cdb6cbc401386a574 Modified Files -------------- src/backend/replication/logical/slotsync.c | 53 ++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 18 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-11-19 03:13 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-19 03:13 pgsql: Don't persist synced slots before a consistent snapshot is built Amit Kapila <akapila@postgresql.org> 2026-11-19 03:13 pgsql: Don't persist synced slots before a consistent snapshot is built Amit Kapila <akapila@postgresql.org>
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