Skip to content

Commit a104e2c

Browse files
author
Arthur Zakirov
committed
Call pg_switch_wal() on replica after pg_create_restore_point() during pg_stop_backup()
1 parent 9709678 commit a104e2c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/backup.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static void backup_files(void *arg);
8080
static void do_backup_database(parray *backup_list);
8181

8282
static void pg_start_backup(const char *label, bool smooth, pgBackup *backup);
83-
static void pg_switch_wal(void);
83+
static void pg_switch_wal(PGconn *conn);
8484
static void pg_stop_backup(pgBackup *backup);
8585
static int checkpoint_timeout(void);
8686

@@ -642,7 +642,7 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
642642
* Do not switch for standby node and if backup is stream.
643643
*/
644644
if (!from_replica && !stream_wal)
645-
pg_switch_wal();
645+
pg_switch_wal(backup_conn);
646646
if (!stream_wal)
647647
/*
648648
* Do not wait start_lsn for stream backup.
@@ -656,20 +656,20 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
656656
* Switch to a new WAL segment. It should be called only for master.
657657
*/
658658
static void
659-
pg_switch_wal(void)
659+
pg_switch_wal(PGconn *conn)
660660
{
661661
PGresult *res;
662662

663663
/* Remove annoying NOTICE messages generated by backend */
664-
res = pgut_execute(backup_conn, "SET client_min_messages = warning;", 0,
664+
res = pgut_execute(conn, "SET client_min_messages = warning;", 0,
665665
NULL);
666666
PQclear(res);
667667

668668
if (server_version >= 100000)
669-
res = pgut_execute(backup_conn, "SELECT * FROM pg_switch_wal()", 0,
669+
res = pgut_execute(conn, "SELECT * FROM pg_switch_wal()", 0,
670670
NULL);
671671
else
672-
res = pgut_execute(backup_conn, "SELECT * FROM pg_switch_xlog()", 0,
672+
res = pgut_execute(conn, "SELECT * FROM pg_switch_xlog()", 0,
673673
NULL);
674674

675675
PQclear(res);
@@ -973,6 +973,9 @@ pg_stop_backup(pgBackup *backup)
973973
restore_lsn = (XLogRecPtr) ((uint64) xlogid << 32) | xrecoff;
974974
PQclear(res);
975975

976+
/* Switch WAL on master to retreive restore_lsn */
977+
pg_switch_wal(master_conn);
978+
976979
/* Wait for restore_lsn from master */
977980
while (true)
978981
{

0 commit comments

Comments
 (0)