Fix recently added incorrect assertion
Commit df3737a651f4 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
This commit is contained in:
parent
2e0d80c5bb
commit
8328a15f8f
@ -8841,9 +8841,8 @@ do_pg_abort_backup(int code, Datum arg)
|
|||||||
{
|
{
|
||||||
bool during_backup_start = DatumGetBool(arg);
|
bool during_backup_start = DatumGetBool(arg);
|
||||||
|
|
||||||
/* Only one of these conditions can be true */
|
/* If called during backup start, there shouldn't be one already running */
|
||||||
Assert(during_backup_start ^
|
Assert(!during_backup_start || sessionBackupState == SESSION_BACKUP_NONE);
|
||||||
(sessionBackupState == SESSION_BACKUP_RUNNING));
|
|
||||||
|
|
||||||
if (during_backup_start || sessionBackupState != SESSION_BACKUP_NONE)
|
if (during_backup_start || sessionBackupState != SESSION_BACKUP_NONE)
|
||||||
{
|
{
|
||||||
|
@ -248,4 +248,18 @@ my $logfile = slurp_file($standby2->logfile, $log_location);
|
|||||||
ok( $logfile =~ qr/archiver process shutting down/,
|
ok( $logfile =~ qr/archiver process shutting down/,
|
||||||
'check shutdown callback of shell archive module');
|
'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();
|
done_testing();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user