1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +03:00

Kill dead-end children when there's nothing else left

Previously, the postmaster would never try to kill dead-end child
processes, even if there were no other processes left. A dead-end
backend will eventually exit, when authentication_timeout expires, but
if a dead-end backend is the only thing that's preventing the server
from shutting down, it seems better to kill it immediately. It's
particularly important, if there was a bug in the early startup code
that prevented a dead-end child from timing out and exiting normally.

Includes a test for that case where a dead-end backend previously
prevented the server from shutting down.

Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/a102f15f-eac4-4ff2-af02-f9ff209ec66f@iki.fi
This commit is contained in:
Heikki Linnakangas
2024-11-14 16:12:04 +02:00
parent 18d67a8d7d
commit bb861414fe
4 changed files with 116 additions and 10 deletions

View File

@@ -1194,6 +1194,9 @@ this to fail. Otherwise, tests might fail to detect server crashes.
With optional extra param fail_ok => 1, returns 0 for failure
instead of bailing out.
The optional extra param timeout can be used to pass the pg_ctl
--timeout option.
=cut
sub stop
@@ -1209,8 +1212,11 @@ sub stop
return 1 unless defined $self->{_pid};
print "### Stopping node \"$name\" using mode $mode\n";
$ret = PostgreSQL::Test::Utils::system_log('pg_ctl', '-D', $pgdata,
'-m', $mode, 'stop');
my @cmd = ('pg_ctl', '-D', $pgdata, '-m', $mode, 'stop');
if ($params{timeout}) {
push(@cmd, ('--timeout', $params{timeout}));
}
$ret = PostgreSQL::Test::Utils::system_log(@cmd);
if ($ret != 0)
{