Erro no Postgres ao atualizar de 3.3 para 3.4 causado por problemas de locale

Olá

Feliz Ano Novo a todos. Estou tentando atualizar da versão 3.3 b10 para a 3.4 b3. Fiz o seguinte:

cd /var/discourse/git
git remote update
git pull --rebase origin main

Em seguida, executei o comando padrão ./launcher rebuild app.

Estou rodando o Ubuntu 20.04 com o Docker 20.10.7. Entendo que a versão do Docker está desatualizada, mas os problemas parecem vir do container do Postgre.

Estou recebendo o seguinte erro de locale:

Stopping old container
+ /usr/bin/docker stop -t 600 app
app
2.0.20241203-0251: Pulling from discourse/base
Digest: sha256:d5d4e6d361d56745e37f2609db58a6970cc9b3fcd26d0b2dcba23d0cb581f067
Status: Image is up to date for discourse/base:2.0.20241203-0251
docker.io/discourse/base:2.0.20241203-0251
/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
/usr/local/bin/pups --stdin
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8)
I, [2025-01-02T00:29:38.387006 #1]  INFO -- : Reading from stdin
I, [2025-01-02T00:29:38.394543 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown: 
I, [2025-01-02T00:29:38.397263 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown: 
I, [2025-01-02T00:29:38.400022 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown: 
I, [2025-01-02T00:29:38.402670 #1]  INFO -- : File > /root/install_postgres  chmod: +x  chown: 
I, [2025-01-02T00:29:38.405305 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown: 
I, [2025-01-02T00:29:38.405637 #1]  INFO -- : Replacing data_directory = '/var/lib/postgresql/13/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/13/main/postgresql.conf
I, [2025-01-02T00:29:38.406337 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/13/main/postgresql.conf
I, [2025-01-02T00:29:38.470425 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/13/main/postgresql.conf
I, [2025-01-02T00:29:38.501384 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/13/main/postgresql.conf
I, [2025-01-02T00:29:38.501924 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/13/main/postgresql.conf
I, [2025-01-02T00:29:38.502432 #1]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' in /etc/postgresql/13/main/postgresql.conf
I, [2025-01-02T00:29:38.502928 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/13/main/postgresql.conf
I, [2025-01-02T00:29:38.503401 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/13/main/postgresql.conf
I, [2025-01-02T00:29:38.503882 #1]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/13/main/postgresql.conf
I, [2025-01-02T00:29:38.504384 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/13/main/pg_hba.conf
I, [2025-01-02T00:29:38.504883 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/13/main/pg_hba.conf
I, [2025-01-02T00:29:38.505325 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*::1\/128.*$) with host all all ::/0 md5 in /etc/postgresql/13/main/pg_hba.conf
I, [2025-01-02T00:29:38.505810 #1]  INFO -- : > if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi

/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8)
failed to set locale!
[error] character map file `UTF-8' not found: No such file or directory
failed to set locale!
[error] default character map file `ANSI_X3.4-1968' not found: No such file or directory
failed to set locale!
[error] character map file `UTF-8' not found: No such file or directory
failed to set locale!
[error] default character map file `ANSI_X3.4-1968' not found: No such file or directory
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_GB.UTF-8",
	LC_ALL = "en_GB.UTF-8",
	LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
I, [2025-01-02T00:29:41.001456 #1]  INFO -- : Generating locales (this might take a while)...
  en_GB.UTF-8... done
  en_US.UTF-8... done
Generation complete.

I, [2025-01-02T00:29:41.002017 #1]  INFO -- : > HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main
I, [2025-01-02T00:29:41.003269 #1]  INFO -- : Terminating async processes
2025-01-02 00:29:41.050 UTC [38] LOG:  starting PostgreSQL 13.18 (Debian 13.18-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2025-01-02 00:29:41.051 UTC [38] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2025-01-02 00:29:41.051 UTC [38] LOG:  listening on IPv6 address "::", port 5432
2025-01-02 00:29:41.053 UTC [38] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-01-02 00:29:41.058 UTC [39] LOG:  database system was shut down at 2025-01-02 00:29:20 UTC
2025-01-02 00:29:41.297 UTC [38] LOG:  database system is ready to accept connections
2025-01-02 00:30:01.915 UTC [46] FATAL:  database locale is incompatible with operating system
2025-01-02 00:30:01.915 UTC [46] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:30:01.915 UTC [46] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:30:21.343 UTC [47] FATAL:  database locale is incompatible with operating system
2025-01-02 00:30:21.343 UTC [47] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:30:21.343 UTC [47] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:30:41.344 UTC [48] FATAL:  database locale is incompatible with operating system
2025-01-02 00:30:41.344 UTC [48] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:30:41.344 UTC [48] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:31:01.341 UTC [49] FATAL:  database locale is incompatible with operating system
2025-01-02 00:31:01.341 UTC [49] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:31:01.341 UTC [49] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:31:21.418 UTC [50] FATAL:  database locale is incompatible with operating system
2025-01-02 00:31:21.418 UTC [50] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:31:21.418 UTC [50] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:31:41.360 UTC [51] FATAL:  database locale is incompatible with operating system
2025-01-02 00:31:41.360 UTC [51] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:31:41.360 UTC [51] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:32:01.358 UTC [52] FATAL:  database locale is incompatible with operating system
2025-01-02 00:32:01.358 UTC [52] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:32:01.358 UTC [52] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:32:21.379 UTC [53] FATAL:  database locale is incompatible with operating system
2025-01-02 00:32:21.379 UTC [53] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:32:21.379 UTC [53] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:32:41.380 UTC [54] FATAL:  database locale is incompatible with operating system
2025-01-02 00:32:41.380 UTC [54] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:32:41.380 UTC [54] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:33:01.373 UTC [55] FATAL:  database locale is incompatible with operating system
2025-01-02 00:33:01.373 UTC [55] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:33:01.373 UTC [55] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:33:21.391 UTC [56] FATAL:  database locale is incompatible with operating system
2025-01-02 00:33:21.391 UTC [56] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:33:21.391 UTC [56] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:33:41.391 UTC [57] FATAL:  database locale is incompatible with operating system
2025-01-02 00:33:41.391 UTC [57] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:33:41.391 UTC [57] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:34:01.391 UTC [58] FATAL:  database locale is incompatible with operating system
2025-01-02 00:34:01.391 UTC [58] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:34:01.391 UTC [58] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:34:21.391 UTC [59] FATAL:  database locale is incompatible with operating system
2025-01-02 00:34:21.391 UTC [59] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:34:21.391 UTC [59] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:34:41.409 UTC [60] FATAL:  database locale is incompatible with operating system
2025-01-02 00:34:41.409 UTC [60] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:34:41.409 UTC [60] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:35:01.405 UTC [61] FATAL:  database locale is incompatible with operating system
2025-01-02 00:35:01.405 UTC [61] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:35:01.405 UTC [61] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:35:21.392 UTC [62] FATAL:  database locale is incompatible with operating system
2025-01-02 00:35:21.392 UTC [62] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:35:21.392 UTC [62] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:35:41.423 UTC [63] FATAL:  database locale is incompatible with operating system
2025-01-02 00:35:41.423 UTC [63] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:35:41.423 UTC [63] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:36:01.421 UTC [64] FATAL:  database locale is incompatible with operating system
2025-01-02 00:36:01.421 UTC [64] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:36:01.421 UTC [64] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:36:21.392 UTC [65] FATAL:  database locale is incompatible with operating system
2025-01-02 00:36:21.392 UTC [65] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:36:21.392 UTC [65] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:36:41.434 UTC [66] FATAL:  database locale is incompatible with operating system
2025-01-02 00:36:41.434 UTC [66] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:36:41.434 UTC [66] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:37:01.437 UTC [67] FATAL:  database locale is incompatible with operating system
2025-01-02 00:37:01.437 UTC [67] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:37:01.437 UTC [67] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:37:21.391 UTC [68] FATAL:  database locale is incompatible with operating system
2025-01-02 00:37:21.391 UTC [68] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:37:21.391 UTC [68] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:37:41.533 UTC [69] FATAL:  database locale is incompatible with operating system
2025-01-02 00:37:41.533 UTC [69] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:37:41.533 UTC [69] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:38:01.454 UTC [70] FATAL:  database locale is incompatible with operating system
2025-01-02 00:38:01.454 UTC [70] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:38:01.454 UTC [70] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:38:21.491 UTC [71] FATAL:  database locale is incompatible with operating system
2025-01-02 00:38:21.491 UTC [71] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:38:21.491 UTC [71] HINT:  Recreate the database with another locale or install the missing locale.
lo^C^C^C^C^C^C2025-01-02 00:38:41.553 UTC [72] FATAL:  database locale is incompatible with operating system
2025-01-02 00:38:41.553 UTC [72] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:38:41.553 UTC [72] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:39:01.470 UTC [73] FATAL:  database locale is incompatible with operating system
2025-01-02 00:39:01.470 UTC [73] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:39:01.470 UTC [73] HINT:  Recreate the database with another locale or install the missing locale.
2025-01-02 00:39:21.511 UTC [74] FATAL:  database locale is incompatible with operating system
2025-01-02 00:39:21.511 UTC [74] DETAIL:  The database was initialized with LC_COLLATE "en_GB.UTF-8",  which is not recognized by setlocale().
2025-01-02 00:39:21.511 UTC [74] HINT:  Recreate the database with another locale or install the missing locale.

Não consigo ver como isso pode ser um problema do host, mas para descartar tal possibilidade, verifiquei se os locales estão corretos no sistema do host:

root@discourse:/var/discourse# locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IL
en_IL.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

Posso ver que eles estão presentes.
Executar novamente o ./launcher rebuild app não ajuda e o mesmo problema persiste. É estranho, pois vejo que os locales estão sendo gerados no container, mas claramente não são suficientes para satisfazer o Postgre.

Alguma dica?

Talvez relacionado à sua alteração @featheredtoast?

2 curtidas

Se você adicionar o seguinte ao seu arquivo de definição de contêiner, isso deverá resolver o problema.

env:
  LANG: en_GB.UTF-8
5 curtidas

Obrigado pelas respostas rápidas.

Mas eu vejo:

I, [2025-01-02T00:29:41.001456 #1]  INFO -- : Gerando locais (isso pode levar um tempo)...
  en_GB.UTF-8... concluído
  en_US.UTF-8... concluído

Só para constar, eu fiz o dist-upgrade completo do sistema Ubuntu 20.04, então a versão do Docker agora é:

Versão do Docker 24.0.7, build 24.0.7-0ubuntu2~20.04.1

Meu repositório discourse_docker está em:

commit 0d0e1eb1de3dbffc432dff6bf03ebcf64d84150b (HEAD -> main, origin/main, origin/HEAD)
Author: Alan Guo Xiang Tan <gxtan1990@gmail.com>
Date:   Fri Dec 27 12:51:33 2024 +0800

    Clean up firefox tar file in `discourse/discourse_test` image (#904)

Eu executei uma reconstrução após atualizar o Docker. Isso funcionou. Como resultado: você ainda recomendaria que eu definisse essa variável @tgxworld?

Abraços

Sam

1 curtida

Sim, por favor, continue a definir o env.

2 curtidas

Parece que tenho um problema semelhante :confused:

Atualizei o fórum através da interface de administração e ele não iniciou. Então tentei reconstruir a partir do console.

Meu ambiente está configurado para polonês:

env:
  LANG: pl_PL.UTF-8

Alterar isso para qualquer outra coisa não ajuda.

Os locais existem:

ubuntu@vps:/var/discourse/containers$ locale -a
C
C.UTF-8
POSIX
en_US.utf8
pl_PL.utf8

Isso é o que tem acontecido nos últimos 2 anos…

Mas recebo esta falha na reconstrução:

falha ao definir o locale!
[erro] arquivo de mapa de caracteres `UTF-8' não encontrado: Arquivo ou diretório inexistente
falha ao definir o locale!
[erro] arquivo de mapa de caracteres padrão `ANSI_X3.4-1968' não encontrado: Arquivo ou diretório inexistente
falha ao definir o locale!
[erro] arquivo de mapa de caracteres `UTF-8' não encontrado: Arquivo ou diretório inexistente
falha ao definir o locale!
[erro] arquivo de mapa de caracteres padrão `ANSI_X3.4-1968' não encontrado: Arquivo ou diretório inexistente
perl: aviso: falha ao definir o locale.
perl: aviso: Por favor, verifique se as suas configurações de locale:
        LANGUAGE = "en_US.UTF-8",
        LC_ALL = "en_US.UTF-8",
        LANG = "pl_PL.UTF-8"
    são suportadas e instaladas no seu sistema.
perl: aviso: Voltando para o locale padrão ("C").
I, [2025-01-06T10:08:48.737950 #1]  INFO -- : Gerando locales (isso pode levar um tempo)...
  en_US.UTF-8... concluído
  pl_PL.UTF-8... concluído
Geração completa.

E então ele começa a entrar em loop com esses erros:

2025-01-06 10:09:48.880 UTC [47] FATAL:  o locale do banco de dados é incompatível com o sistema operacional
2025-01-06 10:09:48.880 UTC [47] DETAIL:  O banco de dados foi inicializado com LC_COLLATE "en_US.UTF-8", que não é reconhecido por setlocale().
2025-01-06 10:09:48.880 UTC [47] HINT:  Recrie o banco de dados com outro locale ou instale o locale ausente.

Qual é a sua versão do Docker? Para mim, isso pareceu resolver as coisas.

2 curtidas

AVISO: Versão do Docker 20.10.8 obsoleta, recomenda-se a atualização para 24.0.7 ou mais recente.
então acho que é isso ;]

ubuntu@vps-d6490d26:/var/discourse/containers$ docker --version
Docker version 20.10.8, build 3967d7

o apt-get relata que esta é a versão mais recente. Estou executando o Ubuntu 20.10

3 curtidas

Sim, atualizar o Docker para 27.4.1 resolveu isso, embora eu tenha que primeiro atualizar meu Ubuntu de 20.10 para 22.04, mas isso é culpa minha ;]

6 curtidas