Reset Postgres encoding after install (Katello) on CentOS7

I followed the basic install for Katello 3.16 as per the wiki, but encountered a problem after install when I adding repository and trying to sync them.
Initially I could not see any error when doing a normal sync, I had to do an “advanced complete sync” to see the error was:

Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8

After digging for hours in the wrong places, I realised this was not the OS or Python throwing this error, but instead Postgres.

It appears that when I install Katello, as per wiki, on the recommended CentOS7 AMI for AWS, Postgres somehow does not know the locale and use SQL_ASCII instead for the pulpcore database. This in turn prevents packages from syncing. (I did not dig too much into this, but it does appear that CentOS has some locale settings missing.)

Fixing it is fairly easy and does not seem to break functionality further along the line. Just update the DB’s to use UTF8 instead of SQL_ASCII:

UPDATE pg_database SET encoding = pg_char_to_encoding('UTF8') WHERE datname = 'postgres';
UPDATE pg_database SET encoding = pg_char_to_encoding('UTF8') WHERE datname = 'template0';
UPDATE pg_database SET encoding = pg_char_to_encoding('UTF8') WHERE datname = 'template1';
UPDATE pg_database SET encoding = pg_char_to_encoding('UTF8') WHERE datname = 'pulpcore';

Restart for good measure and then try to add repos again.

2 Likes