diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2015-03-19 16:12:44 +0100 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2015-03-19 16:15:49 +0100 |
commit | 15ce19792aff0368c6a1132420c40950f7a18577 (patch) | |
tree | 4a571ff88d2225f0d0ac0fd1e4b648bc825711c3 | |
parent | ba77bef2997e98db3a89a3c572189e70b953df67 (diff) | |
download | postgresql-setup-15ce19792aff0368c6a1132420c40950f7a18577.tar.gz postgresql-setup-15ce19792aff0368c6a1132420c40950f7a18577.tar.xz postgresql-setup-15ce19792aff0368c6a1132420c40950f7a18577.zip |
postgresql-setup: upgrade & avoid running old serverv3.1
* postgresql-setup.in (upgrade): Call old_data_in_use to ensure
that the old database server is not running.
(old_data_in_use): New function.
($cleaup): Rename to $failure_cleanup.
* NEWS: Document.
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | postgresql-setup.in | 22 |
2 files changed, 22 insertions, 5 deletions
@@ -1,5 +1,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +New in 3.1 version + +* When doing --upgrade, postgresql-setup now guards against upgrading when + the old postgresql server is still running. + Bugfixes in 3.1 version * The 'pg_upgrade --link' option is not used for non-in-place upgrades diff --git a/postgresql-setup.in b/postgresql-setup.in index 8b30d71..fd1bef2 100644 --- a/postgresql-setup.in +++ b/postgresql-setup.in @@ -175,6 +175,15 @@ initdb() } +old_data_in_use() +{ + local pidfile="$pgdataold/postmaster.pid" + test -f "$pidfile" || return 1 + error $"The pidfile '$pidfile' exists. Verify that there is no postmaster" + error_q $"running the $pgdataold directory." +} + + upgrade() { local inplace=false @@ -245,13 +254,16 @@ upgrade() pghost_override="PGHOST='$upgradefrom_pghost_override'" } - local cleanup=true - - if ! check_not_initialized; then + local failure_cleanup=true + if old_data_in_use; then + script_result=1 + # Cleanup makes sense once perform_initdb gets called. + failure_cleanup=false + elif ! check_not_initialized; then # Don't try to re-init initialized data directory and also do not # remove it after this unsuccessful upgrade. - cleanup=false script_result=1 + failure_cleanup=false elif perform_initdb; then $inplace && link_option=--link @@ -292,7 +304,7 @@ upgrade() warn $pgdataold. else # Clean up after failure. - $cleanup && rm -rf "$pgdata" + $failure_cleanup && rm -rf "$pgdata" $inplace && mv "$pgdataold" "$pgdata" error $"Upgrade failed." fi |