ANXS / postgresql

Fairly full featured Ansible role for Postgresql.
http://anxs.io/
MIT License
854 stars 575 forks source link

Postgresql requires restart if a new locale was used #539

Closed bleetube closed 1 year ago

bleetube commented 1 year ago

msg": "Database query failed: invalid locale name: \"en_US.UTF-8\"\n"}

I've seen this happen a couple times with Ubuntu 22.04, where I couldn't actually use a en_US.UTF-8. I could be wrong, but it looks like the role is not restarting postgresql when we start using a new locale.

# locale -a
C
C.utf8
POSIX
en_US.utf8
root@wartortle:~# su - postgres
root@wartortle:~# su - postgres
postgres@wartortle:~$ psql -c "CREATE DATABASE db WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';"
ERROR:  invalid locale name: "en_US.UTF-8"
postgres@wartortle:~$ exit
logout
root@wartortle:~# systemctl restart postgresql
root@wartortle:~# su - postgres
postgres@wartortle:~$ psql -c "CREATE DATABASE db WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';"
CREATE DATABASE

Showing the manual commands to reproduce and then workaround this issue since that's more straightforward than showing my playbook.

I am running PG15 with PR https://github.com/ANXS/postgresql/pull/534

I'll pre-emptively close this issue since its pretty minor, but it can be opened later if development picks up again and someone can think of a clever fix. I'm guessing it will be a bad trade-off to restart the database without the user initiating that. But at least anyone else who runs into this problem might find this clue and not lose an extra twenty minutes.