Skip to content

Commit a1ceeec

Browse files
author
Sokolov Yura
committed
cfs: protect from "abort_backup during stop_backup"
1 parent de748f3 commit a1ceeec

File tree

1 file changed

+13
-2
lines changed
  • src/backend/access/transam

1 file changed

+13
-2
lines changed

src/backend/access/transam/xlog.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ int wal_level = WAL_LEVEL_MINIMAL;
103103
int CommitDelay = 0; /* precommit delay in microseconds */
104104
int CommitSiblings = 5; /* # concurrent xacts needed to sleep */
105105
int wal_retrieve_retry_interval = 5000;
106+
bool cfs_lock_taken = false;
106107

107108
TransactionId start_xid = 0;
108109
MultiXactId start_mx_id = 0;
@@ -9894,6 +9895,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
98949895
WALInsertLockRelease();
98959896

98969897
cfs_control_gc_lock(); /* disable GC during backup */
9898+
cfs_lock_taken = true;
98979899

98989900
/* Ensure we release forcePageWrites if fail below */
98999901
PG_ENSURE_ERROR_CLEANUP(pg_start_backup_callback, (Datum) BoolGetDatum(exclusive));
@@ -10272,7 +10274,11 @@ pg_start_backup_callback(int code, Datum arg)
1027210274
}
1027310275
WALInsertLockRelease();
1027410276

10275-
cfs_control_gc_unlock(); /* Restore CFS GC activity */
10277+
if (cfs_lock_taken)
10278+
{
10279+
cfs_lock_taken = false;
10280+
cfs_control_gc_unlock(); /* Restore CFS GC activity */
10281+
}
1027610282
}
1027710283

1027810284
/*
@@ -10472,6 +10478,7 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
1047210478
/* Clean up session-level lock */
1047310479
sessionBackupState = SESSION_BACKUP_NONE;
1047410480

10481+
cfs_lock_taken = false;
1047510482
cfs_control_gc_unlock(); /* Restore CFS GC activity */
1047610483

1047710484
/*
@@ -10717,7 +10724,11 @@ do_pg_abort_backup(void)
1071710724
}
1071810725
WALInsertLockRelease();
1071910726

10720-
cfs_control_gc_unlock(); /* Restore CFS GC activity */
10727+
if (cfs_lock_taken)
10728+
{
10729+
cfs_lock_taken = false;
10730+
cfs_control_gc_unlock(); /* Restore CFS GC activity */
10731+
}
1072110732
}
1072210733

1072310734
/*

0 commit comments

Comments
 (0)