PostgreSQL 15 update

Upgrade on ARM (aarch64) with non default locale

I just spent some time fixing a faulty upgrade on a single server with two container setup.

  1. Its CPU is ARM
  2. Discourse was configured with en_UK.UTF-8 locale

Step by step, I figured that:

  1. tianon/postgres-upgrade:13-to-15 does not work on ARM
  2. locale configuration is stored in the share/${CONTAINER}/postgres_data/postgresql.conf

I started with commenting out the env: part of the data container, to ensure it uses default locales.

So, to get out of the upgrade mess, I took a dangerous step, assuming collation differences between en_GB and en_US were negligible, and I ruthlessly updated the whole cluster to en_US:

UPDATE pg_database SET datctype='en_US.UTF-8', datcollate='en_US.UTF-8';

I’m not sure this step is required, YMMV. I leave it here for others more knowledgeable to comment, and I do not recommend it at all for different languages!

Then I replaced the locale in postgresql.conf:

sed -i -e 's/en_GB/en_US/g' shared/data/postgres_data/postgresql.conf
sudo -H -u discourse ./launcher rebuild data
...
UPGRADE OF POSTGRES COMPLETE

:tada:

Do not think it was easy: I’m not mentioning the long path of exploring options, especially as when I intervened, the admin interface was unavailable, and the last backup was made 6 days ago. I had to fiddle around before I could get to a proper – or at least, working – resolution.

I hope this will save some people some time.

5 Likes