]> git.ipfire.org Git - thirdparty/postgresql.git/commit
pg_recvlogical: Prevent flushed data from being re-sent.
authorFujii Masao <fujii@postgresql.org>
Fri, 16 Jan 2026 03:35:26 +0000 (12:35 +0900)
committerFujii Masao <fujii@postgresql.org>
Fri, 16 Jan 2026 03:35:26 +0000 (12:35 +0900)
commit41cbdab0ab6d04e8ec42d10335ef9635eb9c2c67
treeac9d4f82e3f343604701db68fead0907320331d4
parenta7c63e486050636925f81123b1427f1cb49644a2
pg_recvlogical: Prevent flushed data from being re-sent.

Previously, when pg_recvlogical lost connection, reconnected, and restarted
replication, data that had already been flushed could be streamed again.
This happened because the replication start position used when restarting
replication was taken from the last standby status message, which could be
older than the position of the last flushed data. As a result, some flushed
data newer than the replication start position could exist and be re-sent.

This commit fixes the issue by ensuring all written data is flushed to disk
before restarting replication, and by using the last flushed position as
the replication start point. This prevents already flushed data from being
re-sent.

Additionally, previously when the --no-loop option was used, pg_recvlogical
could exit without flushing written data, potentially losing data. To fix
this issue, this commit also ensures all data is flushed to disk before
exiting due to --no-loop.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Mircea Cadariu <cadariu.mircea@gmail.com>
Reviewed-by: Yilin Zhang <jiezhilove@126.com>
Reviewed-by: Dewei Dai <daidewei1970@163.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwFeTymZQ7RLvMU6WuDGar8bUQCazg=VOfA-9GeBkg-FzA@mail.gmail.com
src/bin/pg_basebackup/pg_recvlogical.c