Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit33f74b8

Browse files
author
Amit Kapila
committed
Fix duplicate transaction replay during pg_createsubscriber.
Previously, the tool could replay the same transaction twice, once duringrecovery, then again during replication after the subscriber was set up.This occurred because the same recovery_target_lsn was used both tofinalize recovery and to start replication. Ifrecovery_target_inclusive = true, the transaction at that LSN would beapplied during recovery and then sent again by the publisher leading toduplication.To prevent this, we now set recovery_target_inclusive = false. Thisensures the transaction at recovery_target_lsn is not reapplied duringrecovery, avoiding duplication when replication begins.Bug #18897Reported-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 introducedDiscussion:https://postgr.es/m/18897-d3db67535860dddb@postgresql.org
1 parenta8acfb1 commit33f74b8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎src/bin/pg_basebackup/pg_createsubscriber.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,17 @@ setup_recovery(const struct LogicalRepInfo *dbinfo, const char *datadir, const c
12501250
appendPQExpBufferStr(recoveryconfcontents,"recovery_target = ''\n");
12511251
appendPQExpBufferStr(recoveryconfcontents,
12521252
"recovery_target_timeline = 'latest'\n");
1253+
1254+
/*
1255+
* Set recovery_target_inclusive = false to avoid reapplying the
1256+
* transaction committed at 'lsn' after subscription is enabled. This is
1257+
* because the provided 'lsn' is also used as the replication start point
1258+
* for the subscription. So, the server can send the transaction committed
1259+
* at that 'lsn' after replication is started which can lead to applying
1260+
* the same transaction twice if we keep recovery_target_inclusive = true.
1261+
*/
12531262
appendPQExpBufferStr(recoveryconfcontents,
1254-
"recovery_target_inclusive =true\n");
1263+
"recovery_target_inclusive =false\n");
12551264
appendPQExpBufferStr(recoveryconfcontents,
12561265
"recovery_target_action = promote\n");
12571266
appendPQExpBufferStr(recoveryconfcontents,"recovery_target_name = ''\n");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp