@@ -80,7 +80,7 @@ static void backup_files(void *arg);
80
80
static void do_backup_database (parray * backup_list );
81
81
82
82
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 );
84
84
static void pg_stop_backup (pgBackup * backup );
85
85
static int checkpoint_timeout (void );
86
86
@@ -642,7 +642,7 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
642
642
* Do not switch for standby node and if backup is stream.
643
643
*/
644
644
if (!from_replica && !stream_wal )
645
- pg_switch_wal ();
645
+ pg_switch_wal (backup_conn );
646
646
if (!stream_wal )
647
647
/*
648
648
* Do not wait start_lsn for stream backup.
@@ -656,20 +656,20 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
656
656
* Switch to a new WAL segment. It should be called only for master.
657
657
*/
658
658
static void
659
- pg_switch_wal (void )
659
+ pg_switch_wal (PGconn * conn )
660
660
{
661
661
PGresult * res ;
662
662
663
663
/* 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 ,
665
665
NULL );
666
666
PQclear (res );
667
667
668
668
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 ,
670
670
NULL );
671
671
else
672
- res = pgut_execute (backup_conn , "SELECT * FROM pg_switch_xlog()" , 0 ,
672
+ res = pgut_execute (conn , "SELECT * FROM pg_switch_xlog()" , 0 ,
673
673
NULL );
674
674
675
675
PQclear (res );
@@ -973,6 +973,9 @@ pg_stop_backup(pgBackup *backup)
973
973
restore_lsn = (XLogRecPtr ) ((uint64 ) xlogid << 32 ) | xrecoff ;
974
974
PQclear (res );
975
975
976
+ /* Switch WAL on master to retreive restore_lsn */
977
+ pg_switch_wal (master_conn );
978
+
976
979
/* Wait for restore_lsn from master */
977
980
while (true)
978
981
{
0 commit comments