aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/xlog.c5
-rw-r--r--src/test/recovery/t/020_archive_status.pl14
2 files changed, 16 insertions, 3 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index dea978a962a..8f10effe3a4 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8841,9 +8841,8 @@ do_pg_abort_backup(int code, Datum arg)
{
bool during_backup_start = DatumGetBool(arg);
- /* Only one of these conditions can be true */
- Assert(during_backup_start ^
- (sessionBackupState == SESSION_BACKUP_RUNNING));
+ /* If called during backup start, there shouldn't be one already running */
+ Assert(!during_backup_start || sessionBackupState == SESSION_BACKUP_NONE);
if (during_backup_start || sessionBackupState != SESSION_BACKUP_NONE)
{
diff --git a/src/test/recovery/t/020_archive_status.pl b/src/test/recovery/t/020_archive_status.pl
index 2108d50073a..fe9ac06b32d 100644
--- a/src/test/recovery/t/020_archive_status.pl
+++ b/src/test/recovery/t/020_archive_status.pl
@@ -248,4 +248,18 @@ my $logfile = slurp_file($standby2->logfile, $log_location);
ok( $logfile =~ qr/archiver process shutting down/,
'check shutdown callback of shell archive module');
+# Test that we can enter and leave backup mode without crashes
+my ($stderr, $cmdret);
+$cmdret = $primary->psql(
+ 'postgres',
+ "SELECT pg_backup_start('onebackup'); "
+ . "SELECT pg_backup_stop();"
+ . "SELECT pg_backup_start(repeat('x', 1026))",
+ stderr => \$stderr);
+is($cmdret, 3, "psql fails correctly");
+like($stderr, qr/backup label too long/, "pg_backup_start fails gracefully");
+$primary->safe_psql('postgres',
+ "SELECT pg_backup_start('onebackup'); SELECT pg_backup_stop();");
+$primary->safe_psql('postgres', "SELECT pg_backup_start('twobackup')");
+
done_testing();