Skip to content

Commit 9f9c95c

Browse files
committed
Wait for start_lsn in pg_start_backup()
1 parent d6ee6b1 commit 9f9c95c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

backup.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,6 @@ do_backup_database(parray *backup_list)
215215
*/
216216
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE)
217217
{
218-
/*
219-
* Switch to a new WAL segment. It is necessary to get archived WAL
220-
* segment, which includes start LSN of current backup.
221-
*
222-
* Do not switch for standby node and if backup is stream.
223-
*/
224-
if (!from_replica && !stream_wal)
225-
pg_switch_wal();
226-
if (!stream_wal)
227-
wait_archive_lsn(current.start_lsn, false);
228218
/*
229219
* Build the page map. Obtain information about changed pages
230220
* reading WAL segments present in archives up to the point
@@ -593,6 +583,17 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
593583
backup->start_lsn = (XLogRecPtr) ((uint64) xlogid << 32) | xrecoff;
594584

595585
PQclear(res);
586+
587+
/*
588+
* Switch to a new WAL segment. It is necessary to get archived WAL
589+
* segment, which includes start LSN of current backup.
590+
*
591+
* Do not switch for standby node and if backup is stream.
592+
*/
593+
if (!from_replica && !stream_wal)
594+
pg_switch_wal();
595+
if (!stream_wal)
596+
wait_archive_lsn(backup->start_lsn, false);
596597
}
597598

598599
/*

0 commit comments

Comments
 (0)