Skip to content

Commit 803c607

Browse files
committed
[Issue #187] Do not wait for WAL segment, previous to WAL segment with START LSN, when running backup in archive mode
1 parent ffdf86d commit 803c607

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/backup.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup,
10931093

10941094
PQclear(res);
10951095

1096-
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE &&
1096+
if ((!stream_wal || current.backup_mode == BACKUP_MODE_DIFF_PAGE) &&
10971097
!backup->from_replica &&
10981098
!(nodeInfo->server_version < 90600 &&
10991099
!nodeInfo->is_superuser))
@@ -1105,17 +1105,14 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup,
11051105
*/
11061106
pg_switch_wal(conn);
11071107

1108-
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE)
1109-
/* In PAGE mode wait for current segment... */
1108+
/* In PAGE mode or in ARCHIVE wal-mode wait for current segment */
1109+
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE ||!stream_wal)
1110+
/*
1111+
* Do not wait start_lsn for stream backup.
1112+
* Because WAL streaming will start after pg_start_backup() in stream
1113+
* mode.
1114+
*/
11101115
wait_wal_lsn(backup->start_lsn, true, backup->tli, false, true, ERROR, false);
1111-
/*
1112-
* Do not wait start_lsn for stream backup.
1113-
* Because WAL streaming will start after pg_start_backup() in stream
1114-
* mode.
1115-
*/
1116-
else if (!stream_wal)
1117-
/* ...for others wait for previous segment */
1118-
wait_wal_lsn(backup->start_lsn, true, backup->tli, true, true, ERROR, false);
11191116
}
11201117

11211118
/*

0 commit comments

Comments
 (0)