Commit a545e896 authored by Martin Pitt's avatar Martin Pitt

* pg_ctlcluster: Use "smart" mode shutdown by default, and add option

  -f/--force to use "fast" -> "immediate" -> kill -9 approach. (LP: #154012)
* debian/init.d-functions: Use --force when stopping all clusters, since
  default smart mode can potentially block forever and thus fail to shut
  down a machine.
parent 4368c84e
......@@ -10,6 +10,7 @@ Bugs:
Transition bugs:
Missing selftest:
- --force option for pg_ctlcluster
Important features:
......
......@@ -5,8 +5,13 @@ postgresql-common (82) UNRELEASED; urgency=low
not regarded as a cluster directory. This reproduces #450565.
* PgCommon.pm, get_versions()/get_version_clusters(): Filter out '.' and
'..' from readdir() output. (Closes: #450565)
* pg_ctlcluster: Use "smart" mode shutdown by default, and add option
-f/--force to use "fast" -> "immediate" -> kill -9 approach. (LP: #154012)
* debian/init.d-functions: Use --force when stopping all clusters, since
default smart mode can potentially block forever and thus fail to shut
down a machine.
-- Martin Pitt <mpitt@debian.org> Sun, 11 Nov 2007 01:35:46 +0100
-- Martin Pitt <mpitt@debian.org> Sun, 11 Nov 2007 01:57:41 +0100
postgresql-common (81) unstable; urgency=low
......
......@@ -29,7 +29,11 @@ do_ctl_all() {
log_progress_msg "$name"
set +e
ERRMSG=$(pg_ctlcluster "$2" "$name" $1 2>&1)
if [ "$1" = "stop" ]; then
ERRMSG=$(pg_ctlcluster --force "$2" "$name" $1 2>&1)
else
ERRMSG=$(pg_ctlcluster "$2" "$name" $1 2>&1)
fi
res=$?
set -e
# Do not fail on success or if cluster is already/not running
......
......@@ -357,28 +357,37 @@ sub stop {
stop_check_pid_file;
if (!fork()) {
close STDOUT;
exec $pg_ctl, '-D', $info{'pgdata'}, '-s', '-w', '-m', 'fast', 'stop';
} else {
wait;
}
if ($force) {
if (!fork()) {
close STDOUT;
exec $pg_ctl, '-D', $info{'pgdata'}, '-s', '-w', '-m', 'fast', 'stop';
} else {
wait;
}
# try harder if "fast" mode does not work
if (-f $info{'pgdata'}.'/postmaster.pid') {
print "(does not shutdown gracefully, now stopping immediately)";
system $pg_ctl, '-D', $info{'pgdata'}, '-s', '-w', '-m', 'immediate', 'stop';
}
# try harder if "fast" mode does not work
if (-f $info{'pgdata'}.'/postmaster.pid') {
print "(does not shutdown gracefully, now stopping immediately)";
system $pg_ctl, '-D', $info{'pgdata'}, '-s', '-w', '-m', 'immediate', 'stop';
}
# if that still not helps, use the big hammer
if (-f $info{'pgdata'}.'/postmaster.pid') {
print "(does not shutdown, killing the process)";
if (open FPID, $info{'pgdata'}.'/postmaster.pid') {
$pid = <FPID>;
close FPID;
# if that still not helps, use the big hammer
if (-f $info{'pgdata'}.'/postmaster.pid') {
print "(does not shutdown, killing the process)";
if (open FPID, $info{'pgdata'}.'/postmaster.pid') {
$pid = <FPID>;
close FPID;
}
kill (9, $pid) if $pid;
unlink $info{'pgdata'}.'/postmaster.pid';
}
} else {
if (!fork()) {
close STDOUT;
exec $pg_ctl, '-D', $info{'pgdata'}, '-s', '-w', 'stop';
} else {
wait;
}
kill (9, $pid) if $pid;
unlink $info{'pgdata'}.'/postmaster.pid';
}
# external_pid_file files are currently not removed by postmaster itself
......@@ -398,7 +407,8 @@ sub reload {
# main
#
exit 1 unless GetOptions ('o|options=s' => \@postmaster_auxoptions);
exit 1 unless GetOptions ('o|options=s' => \@postmaster_auxoptions,
'f|force' => \$force);
if ($#ARGV != 2) {
print "Usage: $0 <version> <cluster> <action>\n";
......@@ -495,13 +505,17 @@ already running, and with 1 on other failure conditions.
=item B<stop>
Stops the L<postmaster(1)> server (and B<pg_autovacuum>, if running) of the
given cluster with increasing force. Initially, the B<fast> mode is used which
rolls back all active transactions and thus shuts down cleanly. If that does
not work, shutdown is attempted again in B<immediate> mode, which can leave the
cluster in an inconsistent state and thus will lead to a recovery run at the
next start. If this still does not help, the B<postmaster> process is killed.
Exits with 0 on success, with 2 if the server is not running, and with 1 on
other failure conditions.
given cluster. By default, "smart" mode is used, which waits until all clients
disconnected.
With the B<--force> option the "fast" mode is used which rolls back all active
transactions, disconnects clients immediately and thus shuts down cleanly. If
that does not work, shutdown is attempted again in "immediate" mode, which can
leave the cluster in an inconsistent state and thus will lead to a recovery run
at the next start. If this still does not help, the B<postmaster> process is
killed. Exits with 0 on success, with 2 if the server is not running, and with
1 on other failure conditions. This mode should only be used when the machine
is about to be shut down.
=item B<restart>
......
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