From 803c607b467a89a970d2a8d87ad2b7735d557fa3 Mon Sep 17 00:00:00 2001 From: Grigory Smolkin Date: Fri, 20 Mar 2020 21:40:40 +0300 Subject: [PATCH] [Issue #187] Do not wait for WAL segment, previous to WAL segment with START LSN, when running backup in archive mode --- src/backup.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/backup.c b/src/backup.c index 183f1b2a..a9151fdf 100644 --- a/src/backup.c +++ b/src/backup.c @@ -1093,7 +1093,7 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup, PQclear(res); - if (current.backup_mode == BACKUP_MODE_DIFF_PAGE && + if ((!stream_wal || current.backup_mode == BACKUP_MODE_DIFF_PAGE) && !backup->from_replica && !(nodeInfo->server_version < 90600 && !nodeInfo->is_superuser)) @@ -1105,17 +1105,14 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup, */ pg_switch_wal(conn); - if (current.backup_mode == BACKUP_MODE_DIFF_PAGE) - /* In PAGE mode wait for current segment... */ + /* In PAGE mode or in ARCHIVE wal-mode wait for current segment */ + if (current.backup_mode == BACKUP_MODE_DIFF_PAGE ||!stream_wal) + /* + * Do not wait start_lsn for stream backup. + * Because WAL streaming will start after pg_start_backup() in stream + * mode. + */ wait_wal_lsn(backup->start_lsn, true, backup->tli, false, true, ERROR, false); - /* - * Do not wait start_lsn for stream backup. - * Because WAL streaming will start after pg_start_backup() in stream - * mode. - */ - else if (!stream_wal) - /* ...for others wait for previous segment */ - wait_wal_lsn(backup->start_lsn, true, backup->tli, true, true, ERROR, false); } /*