pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix standby logical slot creation while enabling logical decodin 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix standby logical slot creation while enabling logical decodin @ 2026-11-24 22:23 Masahiko Sawada <msawada@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Masahiko Sawada @ 2026-11-24 22:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix standby logical slot creation while enabling logical decoding. When creating a logical slot during recovery, we reserve WAL from the last replayed position. However, logical decoding can become enabled before the replay position moves past the XLOG_LOGICAL_DECODING_STATUS_CHANGE record that enables it. During replay, the status is changed before the replay position advances to the end of the record. At the end of recovery, the status is changed before the record is even written, and the replay position never moves past it. A logical slot created concurrently in either window could get a restart_lsn preceding the record, and then fail with "unexpected logical decoding status change 1" when decoding it. Fix by making the restart_lsn of a logical slot created during recovery at least the end LSN of the last record that enabled logical decoding. For this, we now also remember the end LSN of the record written at the end of recovery, and write it while holding LogicalDecodingControlLock so that concurrent slot creation sees it. Oversight in commit 67c20979ce7. Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Discussion: https://postgr.es/m/11c3987c-0be9-4212-8347-9aba81f36580@gmail.com Backpatch-through: 19 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/4931dab89d35c13a5c2e3e1fe8b31b338a965c73 Modified Files -------------- src/backend/replication/logical/logicalctl.c | 65 +++++++++++++++++++------- src/backend/replication/slot.c | 13 +++++- src/include/replication/logicalctl.h | 1 + src/test/recovery/t/051_effective_wal_level.pl | 59 +++++++++++++++++++++++ 4 files changed, 121 insertions(+), 17 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix standby logical slot creation while enabling logical decodin @ 2026-11-24 22:23 Masahiko Sawada <msawada@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Masahiko Sawada @ 2026-11-24 22:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix standby logical slot creation while enabling logical decoding. When creating a logical slot during recovery, we reserve WAL from the last replayed position. However, logical decoding can become enabled before the replay position moves past the XLOG_LOGICAL_DECODING_STATUS_CHANGE record that enables it. During replay, the status is changed before the replay position advances to the end of the record. At the end of recovery, the status is changed before the record is even written, and the replay position never moves past it. A logical slot created concurrently in either window could get a restart_lsn preceding the record, and then fail with "unexpected logical decoding status change 1" when decoding it. Fix by making the restart_lsn of a logical slot created during recovery at least the end LSN of the last record that enabled logical decoding. For this, we now also remember the end LSN of the record written at the end of recovery, and write it while holding LogicalDecodingControlLock so that concurrent slot creation sees it. Oversight in commit 67c20979ce7. Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Discussion: https://postgr.es/m/11c3987c-0be9-4212-8347-9aba81f36580@gmail.com Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/4c1329da8f36aa92867dc1c20b7c6dff44f19e00 Modified Files -------------- src/backend/replication/logical/logicalctl.c | 65 +++++++++++++++++++------- src/backend/replication/slot.c | 13 +++++- src/include/replication/logicalctl.h | 1 + src/test/recovery/t/051_effective_wal_level.pl | 59 +++++++++++++++++++++++ 4 files changed, 121 insertions(+), 17 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-11-24 22:23 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-24 22:23 pgsql: Fix standby logical slot creation while enabling logical decodin Masahiko Sawada <msawada@postgresql.org> 2026-11-24 22:23 pgsql: Fix standby logical slot creation while enabling logical decodin Masahiko Sawada <msawada@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