]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix duplicate transaction replay during pg_createsubscriber.
authorAmit Kapila <akapila@postgresql.org>
Thu, 24 Jul 2025 08:50:40 +0000 (08:50 +0000)
committerAmit Kapila <akapila@postgresql.org>
Thu, 24 Jul 2025 08:50:40 +0000 (08:50 +0000)
commit33f74b806ce3facfc0deb1412ed85d19a44c0553
tree96c9b9ba27b69779102abb341a24e12e71215fcd
parenta8acfb133cf91e53d28ec7025188bfffd747a11a
Fix duplicate transaction replay during pg_createsubscriber.

Previously, the tool could replay the same transaction twice, once during
recovery, then again during replication after the subscriber was set up.

This occurred because the same recovery_target_lsn was used both to
finalize recovery and to start replication. If
recovery_target_inclusive = true, the transaction at that LSN would be
applied during recovery and then sent again by the publisher leading to
duplication.

To prevent this, we now set recovery_target_inclusive = false. This
ensures the transaction at recovery_target_lsn is not reapplied during
recovery, avoiding duplication when replication begins.

Bug #18897
Reported-by: Zane Duffield <duffieldzane@gmail.com>
Author: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 17, where it was introduced
Discussion: https://postgr.es/m/18897-d3db67535860dddb@postgresql.org
src/bin/pg_basebackup/pg_createsubscriber.c