Commit 77a6c368 authored by Christoph Berg's avatar Christoph Berg

pg_ctlcluster: Use "fast" shutdown by default, and remove code to kill -9 the...

pg_ctlcluster: Use "fast" shutdown by default, and remove code to kill -9 the server if it doesn't react to a --force stop. (Closes: #756008)
parent 2ec8ea14
......@@ -5,6 +5,8 @@ postgresql-common (194) UNRELEASED; urgency=medium
* Also save pg_controldata on catversion changes, pg_upgrade needs it.
Spotted by Dagfinn Ilmari Mannsåker, thanks!
* Chown /etc/postgresql to user postgres.
* pg_ctlcluster: Use "fast" shutdown by default, and remove code to kill -9
the server if it doesn't react to a --force stop. (Closes: #756008)
-- Christoph Berg <myon@debian.org> Sun, 02 Sep 2018 21:23:33 +0200
......
......@@ -29,7 +29,7 @@ use POSIX qw(lchown);
my ($version, $cluster, $pg_ctl, $force);
my (@postgres_auxoptions, @pg_ctl_opts_from_cli);
my (%postgresql_conf, %info);
my $mode = 'smart'; # default shutdown mode
my $mode = 'fast'; # default shutdown mode
my $foreground = 0; # don't daemonize, use postgres instead of pg_ctl
my $stdlog = 0; # when run in foreground, still log to the default logfile
......@@ -261,36 +261,18 @@ sub stop {
push @options, split(' ', $pg_ctl_opts_from_file{'pg_ctl_options'})
if defined $pg_ctl_opts_from_file{'pg_ctl_options'} and $pg_ctl_opts_from_file{'pg_ctl_options'} ne '';
if ($force) {
if (!fork()) {
close STDOUT;
exec $pg_ctl, @options, '-m', 'fast';
} else {
wait;
$result = $? >> 8;
}
# try harder if "fast" mode does not work
if (-f $info{'pgdata'}.'/postmaster.pid') {
print "(does not shutdown gracefully, now stopping immediately)\n";
$result = system $pg_ctl, @options, '-m', 'immediate';
}
# if that still not helps, use the big hammer
if (-f $info{'pgdata'}.'/postmaster.pid') {
print "(does not shutdown, killing the process)";
my $pid = read_pidfile ($info{'pgdata'}.'/postmaster.pid');
kill (9, $pid) if $pid;
$result = 0;
}
if (!fork()) {
close STDOUT;
exec $pg_ctl, @options, '-m', ($force ? 'fast' : $mode);
} else {
if (!fork()) {
close STDOUT;
exec $pg_ctl, @options, '-m', $mode;
} else {
wait;
$result = $? >> 8;
}
wait;
$result = $? >> 8;
}
# try harder if forced and server hasn't stopped yet
if ($force and -f $info{'pgdata'}.'/postmaster.pid') {
print "(does not shutdown gracefully, now stopping immediately)\n";
$result = system $pg_ctl, @options, '-m', 'immediate';
}
# external_pid_file files are currently not removed by postgres itself
......@@ -539,8 +521,8 @@ failure conditions.
=item B<stop>
Stops the L<postgres(1)> server of the given cluster. By default, "smart"
shutdown mode is used, which waits until all clients disconnected.
Stops the L<postgres(1)> server of the given cluster. By default, "fast"
shutdown mode is used.
=item B<restart>
......@@ -580,7 +562,7 @@ is about to be shut down.
=item B<-m>|B<--mode> [B<smart>|B<fast>|B<immediate>]
Shutdown mode to use for B<stop> and B<restart> actions, default is B<smart>.
Shutdown mode to use for B<stop> and B<restart> actions, default is B<fast>.
See pg_ctl(1) for documentation.
=item B<--foreground>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment