This exact problem, together with an undocumented and obscure 5-seconds-timeout in pg_upgradecluster's invocation of `pg_ctlcluster stop`, nearly made me pull my hair out yesterday.

I successfully tested the planned upgrade from 9.0 to 9.4 in the staging environment, but because the live database requires more than 5 seconds to properly shutdown, pg_upgradecluster died very early with a nondescript error message, costing me more than an hour hunting down thesource of the problem while production was suffering a scheduled, yet prolonged downtime. The following was its death note:

---- >8 ----
Stopping old cluster...
pg_ctl: server does not shut down
Error: Could not stop old cluster
---- 8< ----

After some frantic digging, I solved the problem by temporarily monkey-patching /usr/bin/pg_upgradecluster to stop the old cluster like presented below:


---- >8 ----
# stopping old cluster, so that we notice early when there are still
# connections
if ($info{'running'}) {
    get_encoding $version, $cluster;
    print "Stopping old cluster...\n";
my @argv = ('pg_ctlcluster', $version, $cluster, 'stop', '-m', 'fast', '--');
    push @argv, ('-t', '30') if $version >= '8.4';
    error "Could not stop old cluster" if system @argv;
}
---- 8< ----

I'm not sure what the reason for the (original; I changed it to 30 to get it to work with our setup and workload) 5s timeout being there is (and I don't think that "trick" with passing additional argv elements after a double-dash down to pg_upgrade is documented anywhere?!); maybe it should just get removed instead of relying on total guesswork about how long it could take to stop a user's cluster (esp. in the default "smart" mode, 5s seems VERY unlikely for busy servers).

Thanks very much for taking note of this problem, and trying to help fix it!
--
Mit freundlichen Grüßen
Johannes Truschnigg
Senior System Administrator
--
mailto:johannes.truschn...@geizhals.at (in dringenden Fällen bitte an i...@geizhals.at)

Geizhals(R) - Preisvergleich Internet Services AG
Obere Donaustrasse 63/2
A-1020 Wien
Tel: +43 1 5811609/87
Fax: +43 1 5811609/55
http://geizhals.at => Preisvergleich für Österreich
http://geizhals.de => Preisvergleich für Deutschland
http://geizhals.eu => Preisvergleich EU-weit
Handelsgericht Wien | FN 197241K | Firmensitz Wien

Reply via email to