Package: postgresql-common
Version: 122
Severity: normal
File: /usr/bin/pg_upgradecluster
Tags: patch

pg_upgradecluster fails to upgrade PostgreSQL cluster owned by regular user.
That is because such a cluster uses /tmp as socket dir and not default
/var/run/postgresql (man pg_createcluster : --socket-dir ) and tablespaces test
in pg_upgradecluster does not handle it.

# pg_lsclusters
Version Cluster   Port Status Owner    Data directory                     Log
file
9.0     wiertel   5433 online wiertel  /home/wiertel/var/lib/postgresql9/
/var/log/postgresql/postgresql-9.0-wiertel.log

# LANG=C pg_upgradecluster 9.0 wiertel /home/wiertel/var/lib/postgresql91
Stopping old cluster...
Disabling connections to the old cluster during upgrade...
Restarting old cluster with restricted connections...
Creating new cluster (configuration: /etc/postgresql/9.1/wiertel, data:
/home/wiertel/var/lib/postgresql91)...
Moving configuration file /home/wiertel/var/lib/postgresql91/postgresql.conf to
/etc/postgresql/9.1/wiertel...
Moving configuration file /home/wiertel/var/lib/postgresql91/pg_hba.conf to
/etc/postgresql/9.1/wiertel...
Moving configuration file /home/wiertel/var/lib/postgresql91/pg_ident.conf to
/etc/postgresql/9.1/wiertel...
Configuring postgresql.conf to use port 5432...
Disabling connections to the new cluster during upgrade...
psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Use of uninitialized value $buffer in string ne at /usr/bin/pg_upgradecluster
line 322.
Error: automatic upgrade of tablespaces is not supported
Re-enabling connections to the old cluster...
Re-enabling connections to the new cluster...
Error during cluster dumping, removing new cluster


Couple lines down the script there is another psql invocation with appropriate
parameters set. Copying those two parameters (-h $oldsocket) solves the
problem.

BTW testing if tablespaces were used in upgraded cluster should probably use
$oldpsql.



-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.0.0 (SMP w/2 CPU cores)
Locale: LANG=pl_PL.utf8, LC_CTYPE=pl_PL.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages postgresql-common depends on:
ii  adduser                   3.113
ii  debconf [debconf-2.0]     1.5.40
ii  logrotate                 3.7.8-6
ii  lsb-base                  3.2-28
ii  postgresql-client-common  122
ii  procps                    1:3.2.8-11
ii  ssl-cert                  1.0.28

postgresql-common recommends no packages.

postgresql-common suggests no packages.
--- orig/pg_upgradecluster	2011-10-06 10:13:02.065741489 +0200
+++ altr/pg_upgradecluster	2011-10-06 10:18:42.519429706 +0200
@@ -315,8 +315,8 @@
     my $buffer;
 
     # check for tablespaces (not supported)
-    open F, '-|', $psql, '-Atc', "SELECT count(*) FROM pg_tablespace WHERE spclocation <> ''" 
-	or die "Calling $psql: $!";
+    open F, '-|', $oldpsql, '-h', $oldsocket, '-d', 'template1', '-Atc', "SELECT count(*) FROM pg_tablespace WHERE spclocation <> ''" 
+	or die "Calling $oldpsql: $!";
     $buffer = <F>;
     close F;
     if ($buffer ne "0\n") {

Reply via email to