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

Commit03b08c8

Browse files
author
Amit Kapila
committed
pg_createsubscriber: Fix an unpredictable recovery wait time.
The problem is that the tool is using the LSN returned bypg_create_logical_replication_slot() as recovery_target_lsn. This LSN isahead of the current WAL position and the recovery waits until thepublisher writes a WAL record to reach the target and ends the recovery.On idle systems, this wait time is unpredictable and could lead to failurein promoting the subscriber. To avoid that, insert a harmless WAL record.Reported-by: Alexander Lakhin and Tom LaneDiagnosed-by: Hayato KurodaAuthor: Euler TaveiraReviewed-by: Hayato Kuroda, Amit KapilaBackpatch-through: 17Discussion:https://postgr.es/m/2377319.1719766794%40sss.pgh.pa.usDiscussion:https://postgr.es/m/CA+TgmoYcY+Wb67NAwaHT7MvxCSeV86oSc+va9hHKaasE42ukyw@mail.gmail.com
1 parentc19615f commit03b08c8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎src/bin/pg_basebackup/pg_createsubscriber.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,28 @@ setup_publisher(struct LogicalRepInfo *dbinfo)
778778
else
779779
exit(1);
780780

781+
/*
782+
* Since we are using the LSN returned by the last replication slot as
783+
* recovery_target_lsn, this LSN is ahead of the current WAL position
784+
* and the recovery waits until the publisher writes a WAL record to
785+
* reach the target and ends the recovery. On idle systems, this wait
786+
* time is unpredictable and could lead to failure in promoting the
787+
* subscriber. To avoid that, insert a harmless WAL record.
788+
*/
789+
if (i==num_dbs-1&& !dry_run)
790+
{
791+
PGresult*res;
792+
793+
res=PQexec(conn,"SELECT pg_log_standby_snapshot()");
794+
if (PQresultStatus(res)!=PGRES_TUPLES_OK)
795+
{
796+
pg_log_error("could not write an additional WAL record: %s",
797+
PQresultErrorMessage(res));
798+
disconnect_database(conn, true);
799+
}
800+
PQclear(res);
801+
}
802+
781803
disconnect_database(conn, false);
782804
}
783805

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp