Skip to content

Commit 8328a15

Browse files
committed
Fix recently added incorrect assertion
Commit df3737a added an incorrect assertion about the preconditions for invoking the backup cleanup callback: it misfires at session end in case a backup completes successfully. Fix it, using coding from Michaël Paquier. Also add some tests for the various cases. Reported by Kyotaro Horiguchi <horikyota.ntt@gmail.com> Discussion: https://postgr.es/m/20221021.161038.1277961198945653224.horikyota.ntt@gmail.com
1 parent 2e0d80c commit 8328a15

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/backend/access/transam/xlog.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8841,9 +8841,8 @@ do_pg_abort_backup(int code, Datum arg)
88418841
{
88428842
bool during_backup_start = DatumGetBool(arg);
88438843

8844-
/* Only one of these conditions can be true */
8845-
Assert(during_backup_start ^
8846-
(sessionBackupState == SESSION_BACKUP_RUNNING));
8844+
/* If called during backup start, there shouldn't be one already running */
8845+
Assert(!during_backup_start || sessionBackupState == SESSION_BACKUP_NONE);
88478846

88488847
if (during_backup_start || sessionBackupState != SESSION_BACKUP_NONE)
88498848
{

src/test/recovery/t/020_archive_status.pl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,18 @@
248248
ok( $logfile =~ qr/archiver process shutting down/,
249249
'check shutdown callback of shell archive module');
250250

251+
# Test that we can enter and leave backup mode without crashes
252+
my ($stderr, $cmdret);
253+
$cmdret = $primary->psql(
254+
'postgres',
255+
"SELECT pg_backup_start('onebackup'); "
256+
. "SELECT pg_backup_stop();"
257+
. "SELECT pg_backup_start(repeat('x', 1026))",
258+
stderr => \$stderr);
259+
is($cmdret, 3, "psql fails correctly");
260+
like($stderr, qr/backup label too long/, "pg_backup_start fails gracefully");
261+
$primary->safe_psql('postgres',
262+
"SELECT pg_backup_start('onebackup'); SELECT pg_backup_stop();");
263+
$primary->safe_psql('postgres', "SELECT pg_backup_start('twobackup')");
264+
251265
done_testing();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy