Ciclo infinito durante l'aggiornamento di postgres

Hi! Each time I launch /launcher rebuild app I get the following message (even if I launch it again) :

UPGRADE OF POSTGRES COMPLETE
Old 9.5 database is stored at /shared/postgres_data_old
To complete the upgrade, rebuild again using:
./launcher rebuild app

What information do you need to help me?

PS: The first time I ran it, the command stoped because I needed more space

Temporarily, I used the templates/postgres.9.5.template.yml template to avoid downtime. The app is running again, but I’d like to finish the update.

When I do a cleanup I get the following message : Old PostgreSQL backup data cluster detected taking up 1.2G detected. Would you like to remove it? (Y/n):

Sounds like a question for @tgxworld, but I am guessing that it failed due to lack of space but somehow didn’t catch that the upgrade had failed.

How much space do you have? And how big is your database?

Can you provide me with the full log generated during the rebuild? Thank you!

Sto riscontrando lo stesso problema da molti mesi e non riesco ad aggiornare la mia installazione.

Il processo va in loop e non riesce mai. Uno dei problemi durante l’esecuzione di rebuild app è questo:
mv: impossibile spostare '/shared/postgres_data' in '/shared/postgres_data_old': Dispositivo o risorsa occupato

Accedendo al Docker, la versione di PostgreSQL che ho è:

/usr/lib/postgresql/10/bin/postgres --version
postgres (PostgreSQL) 10.14 (Debian 10.14-1.pgdg100+1)

Questi sono gli errori che ricevo:

FAILED

--------------------

Pups::ExecError: /root/upgrade_postgres è terminato con errore #<Process::Status: pid 47 exit 1>

Posizione dell'errore: /pups/lib/pups/exec_command.rb:112:in `spawn'

exec fallito con i parametri "/root/upgrade_postgres"

0c74c9de4d4315b63c0ef9055631f38c0cf4b3dd0be6500fd83ca0a5b13e0d9d

** FALLIMENTO DURANTE L'AVVIO ** scorri verso l'alto e cerca i messaggi di errore precedenti, potrebbero essercene piĂą di uno.

./discourse-doctor può aiutare a diagnosticare il problema.

Sembra esserci un problema nello script /pups/lib/pups/exec_command.rb durante l’esecuzione di spawn.

Posso comunque avviare l’app:
./launcher start app

Questi sono i file presenti sotto /shared:

total 48
drwxr-xr-x 12 root      root     4096 Jan 12 13:12 .
drwxr-xr-x 57 root      root     4096 Dec 15 09:09 ..
drwxr-xr-x  3 discourse www-data 4096 Aug 20  2019 backups
drwxr-xr-x  4 root      root     4096 Aug 19  2019 log
drwxr-xr-x  2 postgres  postgres 4096 Aug 19  2019 postgres_backup
drwx------ 20 postgres  postgres 4096 Jan 12 13:14 postgres_data
drwx------ 19 postgres  postgres 4096 Jan 12 13:12 postgres_data_new
drwxrwxr-x  5 postgres  postgres 4096 Jan 12 13:14 postgres_run
drwxr-xr-x  2 redis     redis    4096 Jan 12 13:07 redis_data
drwxr-xr-x  4 root      root     4096 Aug 19  2019 state
drwxr-xr-x  4 discourse www-data 4096 Jan 12 13:14 tmp
drwxr-xr-x  4 discourse www-data 4096 Sep  8  2019 uploads

Cosa posso fare?

La tua directory condivisa è un mount di rete di qualche tipo?

No, ma sono finalmente riuscito a farlo!

I due comandi mv in templates/postgres.template.yml non vengono verificati per la correttezza. Lo script riporta sempre UPGRADE OF POSTGRES COMPLETE, il che non è vero quando lo spostamento fallisce.

Ho rimosso i comandi, poi ho spostato le directory manualmente dopo essere entrato nel container Docker, e il prossimo rebuild app sta funzionando come prima! Sono così felice :smiley:
Grazie.

Ho riscontrato questo problema durante l’ultimo aggiornamento da PostgreSQL 13 a 15.

Nel nostro deployment, la nostra directory /shared/postgres_data è montata su un dispositivo di archiviazione NVMe più veloce, quindi il suo spostamento è fallito con un messaggio di errore Device or resource busy.

Abbiamo risolto questo problema modificando il template di postgres in questo modo:

diff --git a/templates/postgres.template.yml b/templates/postgres.template.yml
index c24bfe6..03813c4 100644
--- a/templates/postgres.template.yml
+++ b/templates/postgres.template.yml
@@ -139,8 +139,10 @@ run:
            exit 1
          fi

-         mv /shared/postgres_data /shared/postgres_data_old
-         mv /shared/postgres_data_new /shared/postgres_data
+         mkdir /shared/postgres_data_old
+         mv /shared/postgres_data/* /shared/postgres_data_old
+         mv /shared/postgres_data_new/* /shared/postgres_data
+         rmdir /shared/postgres_data_new

Invece di tentare di manipolare la directory stessa, spostiamo semplicemente i contenuti.

Si prega di considerare l’integrazione di questa modifica per migliorare l’affidabilità degli aggiornamenti del database.

Penso che questo possa essere correlato: FIX: improve postgres upgrade reliability by jcharaoui · Pull Request #989 · discourse/discourse_docker · GitHub

Il PR è stato unito :+1: