Package: postgresql-common
Version: 181+deb9u2
Severity: important


I was upgrading a few PostgreSQL servers.  Most were successful, one of
them would fail with this error:

# pg_upgradecluster 9.4 main
Error: could not get cluster locales



I checked locale settings on the host (locale ; locale -a), in the
database (show all) and in postgresql.conf.  Nothing obviously wrong.  I
used
 dpkg-reconfigure locales
to install all possible locales too but this didn't resolve the issue.

Web searches find many examples of this error.  Example:

https://serverfault.com/questions/909624/pg-upgradecluster-fails-with-error-could-not-get-cluster-locales?rq=1
"sometimes, in Ubuntu systems, if ssh login user's locale is different"

but that was also a red herring.

https://www.postgresql.org/message-id/CABnTomKNDj%2BorMgyPaPtFkNoBFCuSWnzSAd0X0%2BX4LHSgUbEDQ%40mail.gmail.com

also suggests running pg_upgrade manually.

Another page suggested some users made it work if they manually stop the
service with systemctl before running pg_upgradecluster, that didn't
help me either.

I decided to trace the scripts:

  apt install libdevel-trace-perl

  cp /usr/bin/pg_upgradecluster /tmp

  perl -d:Trace -T /tmp/pg_upgradecluster 9.4 main

The trace output helped me identify where the script was really failing
and add some debugging / print statements.

In my case, I found that it was failing to find the port number.  In
postgresql.conf, the "port" parameter was commented on this host, so it
would use the default, 5432

This leads me to two conclusions:

- it needs to handle these specific cases (e.g. port number) automatically

- it needs to give more accurate errors - in my case, the error "could
not get cluster locales" was misleading for me

Regards,

Daniel

Reply via email to