]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix assertion when decoding XLOG_PARAMETER_CHANGE on promoted primary.
authorMasahiko Sawada <msawada@postgresql.org>
Mon, 24 Feb 2025 22:03:10 +0000 (14:03 -0800)
committerMasahiko Sawada <msawada@postgresql.org>
Mon, 24 Feb 2025 22:03:10 +0000 (14:03 -0800)
commitcc628f66187c56e0bfd1befee298755f7dfbf65e
tree5eff4caa803b8ccb70445ab369753e1cf61c9087
parentd850a6600cec7cf382f875af229f9df329fbcc30
Fix assertion when decoding XLOG_PARAMETER_CHANGE on promoted primary.

When a standby replays an XLOG_PARAMETER_CHANGE record that lowers
wal_level below logical, we invalidate all logical slots in hot
standby mode. However, if this record was replayed while not in hot
standby mode, logical slots could remain valid even after promotion,
potentially causing an assertion failure during WAL record decoding.

To fix this issue, this commit adds a check for hot_standby status
when restoring a logical replication slot on standbys. This check
ensures that logical slots are invalidated when they become
incompatible due to insufficient wal_level during recovery.

Backpatch to v16 where logical decoding on standby was introduced.

Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/CAD21AoABoFwGY_Rh2aeE6tEq3HkJxf0c6UeOXn4VV9v6BAQPSw%40mail.gmail.com
Backpatch-through: 16
src/backend/replication/slot.c
src/test/recovery/t/035_standby_logical_decoding.pl