Skip to content

Commit e7ffc15

Browse files
committed
[Issue #289] Wait for Start LSN after finding the suitable parent backup, not before
1 parent 286d30d commit e7ffc15

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/backup.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,6 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
146146
current.tli = get_current_timeline_from_control(false);
147147
#endif
148148

149-
/* In PAGE mode or in ARCHIVE wal-mode wait for current segment */
150-
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE ||!stream_wal)
151-
/*
152-
* Do not wait start_lsn for stream backup.
153-
* Because WAL streaming will start after pg_start_backup() in stream
154-
* mode.
155-
*/
156-
wait_wal_lsn(current.start_lsn, true, current.tli, false, true, ERROR, false);
157-
158149
/*
159150
* In incremental backup mode ensure that already-validated
160151
* backup on current timeline exists and get its filelist.
@@ -264,10 +255,14 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
264255
/* Update running backup meta with START LSN */
265256
write_backup(&current, true);
266257

267-
join_path_components(external_prefix, current.database_dir, EXTERNAL_DIR);
268-
269-
/* initialize backup's file list */
270-
backup_files_list = parray_new();
258+
/* In PAGE mode or in ARCHIVE wal-mode wait for current segment */
259+
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE || !stream_wal)
260+
/*
261+
* Do not wait start_lsn for stream backup.
262+
* Because WAL streaming will start after pg_start_backup() in stream
263+
* mode.
264+
*/
265+
wait_wal_lsn(current.start_lsn, true, current.tli, false, true, ERROR, false);
271266

272267
/* start stream replication */
273268
if (stream_wal)
@@ -279,6 +274,10 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
279274
current.start_lsn, current.tli);
280275
}
281276

277+
/* initialize backup's file list */
278+
backup_files_list = parray_new();
279+
join_path_components(external_prefix, current.database_dir, EXTERNAL_DIR);
280+
282281
/* list files with the logical path. omit $PGDATA */
283282
if (fio_is_remote(FIO_DB_HOST))
284283
fio_list_dir(backup_files_list, instance_config.pgdata,

0 commit comments

Comments
 (0)