Matrix DB has incorrect locale - Synapse failed to start #92

Open
opened 2022-07-22 13:05:11 +00:00 by graffen · 4 comments
Contributor

After bumping to latest Synapse (1.63.1), container failed to start with the following error message:

Error during initialisation:


    ("Database has incorrect collation of %r. Should be 'C'\nSee docs/postgres.md for more information. You can override this check bysetting 'allow_unsafe_locale' to true in the database config.", 'en_US.utf8')


 There may be more information in the logs.

I don't know if we can simply change the locale on the current DB or whether we need to create a new DB and then migrate data. For now I have hard-coded the setting inside homeserver.yaml.

After bumping to latest Synapse (1.63.1), container failed to start with the following error message: ``` Error during initialisation: ("Database has incorrect collation of %r. Should be 'C'\nSee docs/postgres.md for more information. You can override this check bysetting 'allow_unsafe_locale' to true in the database config.", 'en_US.utf8') There may be more information in the logs. ``` I don't know if we can simply change the locale on the current DB or whether we need to create a new DB and then migrate data. For now I have hard-coded the setting inside `homeserver.yaml`.
Owner

Here's a hint from https://hub.docker.com/_/postgres:

Locale Customization

You can extend the Debian-based images with a simple Dockerfile to set a different locale. The following example will set the default locale to de_DE.utf8:

FROM postgres:14.3
RUN localedef -i de_DE -c -f UTF-8 -A /usr/share/locale/locale.alias de_DE.UTF-8
ENV LANG de_DE.utf8

Since database initialization only happens on container startup, this allows us to set the language before it is created.

Also of note, Alpine-based variants do not support locales; see "Character sets and locale" in the musl documentation for more details.

I think it's likely that we don't need to run localedef for C locale, though.

Here's a hint from https://hub.docker.com/_/postgres: > # Locale Customization > > You can extend the Debian-based images with a simple `Dockerfile` to set a different locale. The following example will set the default locale to `de_DE.utf8`: > > FROM postgres:14.3 > RUN localedef -i de_DE -c -f UTF-8 -A /usr/share/locale/locale.alias de_DE.UTF-8 > ENV LANG de_DE.utf8 > > Since database initialization only happens on container startup, this allows us to set the language before it is created. > > Also of note, Alpine-based variants do not support locales; see ["Character sets and locale" in the musl documentation](https://wiki.musl-libc.org/functional-differences-from-glibc.html#Character-sets-and-locale) for more details. I think it's likely that we don't need to run `localedef` for `C` locale, though.
Author
Contributor

But how do we do it for an existing database. From what I could see the locale is set only on DB creation. Does that mean we have to start with a fresh DB and then try to restore data from the old one (with a different locale)?

But how do we do it for an existing database. From what I could see the locale is set only on DB creation. Does that mean we have to start with a fresh DB and then try to restore data from the old one (with a different locale)?
Owner

(also, why are we running postgres 10? Isn't that quite old?)

(also, why are we running postgres 10? Isn't that quite old?)
Author
Contributor

(also, why are we running postgres 10? Isn't that quite old?)

Yes but last time we tried to upgrade everything broke for some reason. I don't think the upgrade path is straightforward.

> (also, why are we running postgres 10? Isn't that quite old?) Yes but last time we tried to upgrade everything broke for some reason. I don't think the upgrade path is straightforward.
samsapti added the
Existing Service
label 2022-11-16 13:35:18 +00:00
valberg added this to the Devops work project 2024-02-09 07:52:18 +00:00
Sign in to join this conversation.
No description provided.