Aggiornamento fallito. Database fermo. (installazione multisito)

Mi sono collegato. Non aggiorno da 11 mesi. Ho iniziato provando ad aggiornare il Docker Manager. Non sembrava mai completarsi. Il giorno dopo la pagina di amministrazione era praticamente rovinata. Ho provato a eseguire ./launcher rebuild app. Ottengo il seguente errore:

2025-10-30 20:04:52.144 UTC [1892] discourse@c_discourse ERROR:  must be owner of extension vector
2025-10-30 20:04:52.144 UTC [1892] discourse@c_discourse STATEMENT:  ALTER EXTENSION vector UPDATE TO ‘0.7.0’;

Ma il database è fermo, quindi le soluzioni che ho visto non funzionano.

2025-10-31 00:27:40.021 UTC [662] FATAL:  database files are incompatible with server
2025-10-31 00:27:40.021 UTC [662] DETAIL:  The data directory was initialized by PostgreSQL version 15, which is not compatible with this version 13.16 (Debian 13.16-1.pgdg120+1).

Ma

root@main-app:/var/lib/postgresql# pg_config --version
PostgreSQL 16.4 (Debian 16.4-1.pgdg120+1)

EDIT: Sembra che il DB sia ancora in formato 13?

root@main-app:/var/lib/postgresql# ls
13  take-database-backup

Se non hai ancora visto l’argomento Aggiornamento PostgreSQL 15 - Annunci, potresti iniziare da lì. Discute una serie di problemi e raccomandazioni.

2 Mi Piace

Grazie. Troppo per capirlo davvero tutto, ma niente sembra essere il mio problema. :frowning: Il database sembra funzionare durante il processo di ricostruzione, che è la parte strana. Almeno da quello che posso capire dalle cose che scorrono.

Questo di solito non funzionerà dopo 11 mesi.

È assolutamente necessario eseguire l’aggiornamento a postgres 15, ed è parte del problema. È possibile che questo possa passare a postgres 13 e far ripartire le cose prima di eseguire l’aggiornamento.

1 Mi Piace

Questa è un’installazione standard?

Non se il multisito è ancora considerato non supportato.

Il problema sembra essere che quando l’ho installato non c’era un utente/password collegato ai singoli database. Sembra che questo cambi. È qui che risiede il problema. Ho provato a modificarlo un po’ aggiungendo un utente e poi un utente con una password vuota, ma non ha aiutato.

La mia configurazione rispetto alla nuova configurazione di esempio:


secondsite:
adapter: postgresql
database: b_discourse

pool: 25
timeout: 5000
db_id: 2
host_names:

mlp:
adapter: postgresql
database: discourse_mlp
username: discourse_mlp
password: applejack
host: dbhost
pool: 5
timeout: 5000

host_names:

Ciò significa che il database viene effettivamente avviato durante il processo di installazione?

2025-10-31 15:14:30.984 UTC [45] LOG:  starting PostgreSQL 15.14 (Debian 15.14-1.pgdg12+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0
-14+deb12u1) 12.2.0, 64-bit
2025-10-31 15:14:30.984 UTC [45] LOG:  listening on IPv4 address “0.0.0.0”, port 5432
2025-10-31 15:14:30.984 UTC [45] LOG:  listening on IPv6 address “::”, port 5432
2025-10-31 15:14:31.055 UTC [45] LOG:  listening on Unix socket “/var/run/postgresql/.s.PGSQL.5432”
2025-10-31 15:14:31.135 UTC [56] LOG:  database system was shut down at 2025-10-31 02:08:49 UTC
2025-10-31 15:14:31.199 UTC [45] LOG:  database system is ready to accept connections
I, [2025-10-31T15:14:35.760150 #1]  INFO – :
I, [2025-10-31T15:14:35.760557 #1]  INFO – : > /usr/local/bin/create_db
2025-10-31 15:14:35.912 UTC [63] postgres@postgres ERROR:  database “discourse” already exists
2025-10-31 15:14:35.912 UTC [63] postgres@postgres STATEMENT:  CREATE DATABASE discourse;
createdb: error: database creation failed: ERROR:  database “discourse” already exists
2025-10-31 15:14:36.060 UTC [66] postgres@discourse ERROR:  role “discourse” already exists
2025-10-31 15:14:36.060 UTC [66] postgres@discourse STATEMENT:  create user discourse;
ERROR:  role “discourse” already exists
NOTICE:  extension “hstore” already exists, skipping
NOTICE:  extension “pg_trgm” already exists, skipping
NOTICE:  extension “vector” already exists, skipping
NOTICE:  version “0.8.1” of extension “vector” is already installed
NOTICE:  extension “hstore” already exists, skipping
NOTICE:  extension “pg_trgm” already exists, skipping
NOTICE:  extension “vector” already exists, skipping
NOTICE:  version “0.8.1” of extension “vector” is already installed
I, [2025-10-31T15:14:37.265035 #1]  INFO – : GRANT
ALTER SCHEMA
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION
ALTER EXTENSION
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION
ALTER EXTENSION
UPDATE 0

I, [2025-10-31T15:14:37.265325 #1]  INFO – : > echo postgres installed!
I, [2025-10-31T15:14:37.270967 #1]  INFO – : postgres installed!

I, [2025-10-31T15:14:37.271578 #1]  INFO – : > sudo -u postgres createdb b_discourse || exit 0
2025-10-31 15:14:37.380 UTC [104] postgres@postgres ERROR:  database “b_discourse” already exists
2025-10-31 15:14:37.380 UTC [104] postgres@postgres STATEMENT:  CREATE DATABASE b_discourse;
createdb: error: database creation failed: ERROR:  database “b_discourse” already exists
I, [2025-10-31T15:14:37.385149 #1]  INFO – :
I, [2025-10-31T15:14:37.385968 #1]  INFO – : > sudo -u postgres psql b_discourse
I, [2025-10-31T15:14:37.390476 #1]  INFO – : grant all privileges on database b_discourse to discourse;

I, [2025-10-31T15:14:37.515870 #1]  INFO – : > sudo -u postgres createdb c_discourse || exit 0
2025-10-31 15:14:37.625 UTC [111] postgres@postgres ERROR:  database “c_discourse” already exists
2025-10-31 15:14:37.625 UTC [111] postgres@postgres STATEMENT:  CREATE DATABASE c_discourse;
createdb: error: database creation failed: ERROR:  database “c_discourse” already exists
I, [2025-10-31T15:14:37.629387 #1]  INFO – :
I, [2025-10-31T15:14:37.630145 #1]  INFO – : > sudo -u postgres psql c_discourse
I, [2025-10-31T15:14:37.634672 #1]  INFO – : grant all privileges on database c_discourse to discourse;

I, [2025-10-31T15:14:37.758171 #1]  INFO – : > /bin/bash -c ‘sudo -u postgres psql b_discourse <<< “alter schema public owner to discourse;”’
I, [2025-10-31T15:14:37.876557 #1]  INFO – : ALTER SCHEMA

I, [2025-10-31T15:14:37.877104 #1]  INFO – : > /bin/bash -c ‘sudo -u postgres psql b_discourse <<< “create extension if not exists hstore;”’
NOTICE:  extension “hstore” already exists, skipping
I, [2025-10-31T15:14:37.997465 #1]  INFO – : CREATE EXTENSION

I, [2025-10-31T15:14:37.998029 #1]  INFO – : > /bin/bash -c ‘sudo -u postgres psql b_discourse <<< “create extension if not exists pg_trgm;”’
NOTICE:  extension “pg_trgm” already exists, skipping
I, [2025-10-31T15:14:38.117879 #1]  INFO – : CREATE EXTENSION

2025-10-31 15:14:30.984 UTC [45] LOG:  starting PostgreSQL 15.14 (Debian 15.14-1.pgdg12+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0
-14+deb12u1) 12.2.0, 64-bit
2025-10-31 15:14:30.984 UTC [45] LOG:  listening on IPv4 address “0.0.0.0”, port 5432
2025-10-31 15:14:30.984 UTC [45] LOG:  listening on IPv6 address “::”, port 5432
2025-10-31 15:14:31.055 UTC [45] LOG:  listening on Unix socket “/var/run/postgresql/.s.PGSQL.5432”
2025-10-31 15:14:31.135 UTC [56] LOG:  database system was shut down at 2025-10-31 02:08:49 UTC
2025-10-31 15:14:31.199 UTC [45] LOG:  database system is ready to accept connections
I, [2025-10-31T15:14:35.760150 #1]  INFO – :
I, [2025-10-31T15:14:35.760557 #1]  INFO – : > /usr/local/bin/create_db
2025-10-31 15:14:35.912 UTC [63] postgres@postgres ERROR:  database “discourse” already exists
2025-10-31 15:14:35.912 UTC [63] postgres@postgres STATEMENT:  CREATE DATABASE discourse;
createdb: error: database creation failed: ERROR:  database “discourse” already exists
2025-10-31 15:14:36.060 UTC [66] postgres@discourse ERROR:  role “discourse” already exists
2025-10-31 15:14:36.060 UTC [66] postgres@discourse STATEMENT:  create user discourse;
ERROR:  role “discourse” already exists
NOTICE:  extension “hstore” already exists, skipping
NOTICE:  extension “pg_trgm” already exists, skipping
NOTICE:  extension “vector” already exists, skipping
NOTICE:  version “0.8.1” of extension “vector” is already installed
NOTICE:  extension “hstore” already exists, skipping
NOTICE:  extension “pg_trgm” already exists, skipping
NOTICE:  extension “vector” already exists, skipping
NOTICE:  version “0.8.1” of extension “vector” is already installed
I, [2025-10-31T15:14:37.265035 #1]  INFO – : GRANT
ALTER SCHEMA
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION
ALTER EXTENSION
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION
ALTER EXTENSION
UPDATE 0

I, [2025-10-31T15:14:37.265325 #1]  INFO – : > echo postgres installed!
I, [2025-10-31T15:14:37.270967 #1]  INFO – : postgres installed!

I, [2025-10-31T15:14:37.271578 #1]  INFO – : > sudo -u postgres createdb b_discourse || exit 0
2025-10-31 15:14:37.380 UTC [104] postgres@postgres ERROR:  database “b_discourse” already exists
2025-10-31 15:14:37.380 UTC [104] postgres@postgres STATEMENT:  CREATE DATABASE b_discourse;
createdb: error: database creation failed: ERROR:  database “b_discourse” already exists
I, [2025-10-31T15:14:37.385149 #1]  INFO – :
I, [2025-10-31T15:14:37.385968 #1]  INFO – : > sudo -u postgres psql b_discourse
I, [2025-10-31T15:14:37.390476 #1]  INFO – : grant all privileges on database b_discourse to discourse;

I, [2025-10-31T15:14:37.515870 #1]  INFO – : > sudo -u postgres createdb c_discourse || exit 0
2025-10-31 15:14:37.625 UTC [111] postgres@postgres ERROR:  database “c_discourse” already exists
2025-10-31 15:14:37.625 UTC [111] postgres@postgres STATEMENT:  CREATE DATABASE c_discourse;
createdb: error: database creation failed: ERROR:  database “c_discourse” already exists
I, [2025-10-31T15:14:37.629387 #1]  INFO – :
I, [2025-10-31T15:14:37.630145 #1]  INFO – : > sudo -u postgres psql c_discourse
I, [2025-10-31T15:14:37.634672 #1]  INFO – : grant all privileges on database c_discourse to discourse;

I, [2025-10-31T15:14:37.758171 #1]  INFO – : > /bin/bash -c ‘sudo -u postgres psql b_discourse <<< “alter schema public owner to discourse;”’
I, [2025-10-31T15:14:37.876557 #1]  INFO – : ALTER SCHEMA

I, [2025-10-31T15:14:37.877104 #1]  INFO – : > /bin/bash -c ‘sudo -u postgres psql b_discourse <<< “create extension if not exists hstore;”’
NOTICE:  extension “hstore” already exists, skipping
I, [2025-10-31T15:14:37.997465 #1]  INFO – : CREATE EXTENSION

I, [2025-10-31T15:14:37.998029 #1]  INFO – : > /bin/bash -c ‘sudo -u postgres psql b_discourse <<< “create extension if not exists pg_trgm;”’
NOTICE:  extension “pg_trgm” already exists, skipping
I, [2025-10-31T15:14:38.117879 #1]  INFO – : CREATE EXTENSION

L’estensione Pgvector è obsoleta o non è configurata in uno dei tuoi database. Ho riscontrato questo problema in alcune installazioni qualche mese fa. È molto semplice da risolvere, devi solo aggiornarla.

entra nel container del database, esegui psql come discourse (o qualunque sia il proprietario del tuo database) e poi scegli ogni database ed esegui

ALTER EXTENSION vector UPDATE;

1 Mi Piace

Sembra che il proprietario dell’estensione per il database c_discourse non sia l’utente discourse. Dovrai verificare chi è il proprietario, ad esempio:

discourse_development=# select extname, extowner, usename, extversion from pg_extension JOIN pg_user on pg_extension.extowner = pg_user.usesysid;
 extname  | extowner | usename  | extversion
----------+----------+----------+------------
 vector   |    16385 | michael  | 0.8.0
 unaccent |       10 | postgres | 1.1
 pg_trgm  |       10 | postgres | 1.6
 hstore   |       10 | postgres | 1.8
 plpgsql  |       10 | postgres | 1.0

ed esegui il comando di aggiornamento dell’estensione come quell’utente o come superutente del database.

2 Mi Piace

Qualsiasi aiuto su come avviare il database per fare questo? Questo è davvero il punto critico.

EDIT: Gli unici file postgres che trovo sono della versione /13. Quindi sono in una specie di limbo. Sembra che il programma del database sia stato aggiornato ma i file del database no. Ho fatto alcune ricerche ma niente con cui mi senta a mio agio, a parte provare a copiare i file e giocarci.

2025-10-31 00:27:40.021 UTC [662] FATAL: i file del database sono incompatibili con il server
2025-10-31 00:27:40.021 UTC [662] DETAIL: La directory dei dati è stata inizializzata dalla versione 15 di PostgreSQL, che non è compatibile con questa versione 13.16 (Debian 13.16-1.pgdg120+1).

Dovresti essere in grado di modificare app.yml e utilizzare il template postgres 13 e ricompilare, come descritto nell’argomento Aggiornamento PostgreSQL 15.

Quindi puoi ricompilare. Quindi puoi avviare il container. Quindi puoi entrare nel container. Quindi puoi fare le cose con pgvectkr.

Bene, ha rimosso 15 e installato 13, ma stranamente, lo stesso errore. Si è interrotto molto più vicino all’inizio del processo. :frowning:

2025-11-01 15:30:26.522 UTC [2547] FATAL: database files are incompatible with server
2025-11-01 15:30:26.522 UTC [2547] DETAIL: The data directory was initialized by PostgreSQL version 15, which is not compatible with this versio
n 13.22 (Debian 13.22-1.pgdg12+1).

Questo è il punto di fallimento:
2025-11-01 15:30:26.522 UTC [2547] FATAL: database files are incompatible with server
2025-11-01 15:30:26.522 UTC [2547] DETAIL: The data directory was initialized by PostgreSQL version 15, which is not compatible with this versio
n 13.22 (Debian 13.22-1.pgdg12+1).

Ho provato il template 13. Il problema è che il database è già stato modificato da 15 ma la migrazione dei 2 siti multi aggiunti è stata in qualche modo aggiunta con un utente che sembra non essere riconosciuto dall’installer. Come ho detto sopra, non c’era alcun requisito per una combinazione utente/password quando li ho aggiunti inizialmente, quindi non so esattamente come siano stati aggiunti al database.

C’è qualche valore che posso aggiungere alle opzioni utente/password che le soddisfi? Ricorda, non li ho aggiunti io, quindi cosa ha inserito lo script iniziale se non postgres, che sembra essere l’utente predefinito indicato dall’output che vedo.

Sarebbe possibile semplicemente commentare i due siti aggiunti per far funzionare il database e POI magari utilizzare il metodo di importazione che viene utilizzato ora?

Se guardi l’argomento pg 15 ti dirà come rinominare la directory di backup che ha ancora i file pg 13.

Questo è un lungo thread, quindi fammi assicurarmi di guardare la cosa giusta.

  1. Usa il template 13
  2. mv /shared/postgres_data a qualcosa come /shared/postgres_data.bak
  3. mv /shared/postgres_data_old a /shared/postgres_data

E questo farà partire il database con quello vecchio?

root@main-app:/shared/postgres_data_old# cat PG_VERSION
13
root@main-app:/shared/postgres_data# cat PG_VERSION
15

Poi preoccupati di

Il database è sempre stato il mio punto debole. :frowning: Sembra che questo sia strutturato diversamente da quello che pensavo, cioè che tutte queste cose fossero in /var/lib/posgresql sotto una di quelle strane directory con numeri opachi.

Apprezzo tutto l’aiuto. Ci sono alcuni forum in cui sono io quello che scuote la testa davanti ad alcuni utenti. :wink:

Se stai creando una versione di discourse che include plugin in bundle, la build fallirà con l’estensione pgvector mancante indipendentemente dalla versione di postgres su cui ti trovi. Se sei su una versione precedente di postgres, avrai ancora più problemi di quanti ne avessi all’inizio.

Spero tu abbia effettuato un backup prima di questo percorso di aggiornamento.

Suggerirei di configurare una nuova istanza di discourse altrove e ripristinare il tuo backup. Questo è l’unico modo affidabile per uscire da questa situazione.

Puoi farlo anche manualmente, ma richiederà molto più lavoro e non garantirà risultati.

È stata rilasciata una nuova versione ieri sera? Penso di aver visto alcuni pull di git. Comunque, l’utilizzo del template 13 e lo spostamento dei dati ha funzionato. Più o meno. :wink:
Il database sembra essersi migrato correttamente. Non riesco a trovare l’errore di “grant” nelle pagine e pagine di output. Ciò non significa che non ci sia. Potrei dover eseguire discourse_doctor in modo da avere un output salvato che posso cercare per errori. Il DB è attivo e funzionante. Ora ho un errore di pagina invece di un “bad gateway” nel mio browser. Includerò l’ultima parte dell’output qui per completezza, ma se non trovo lo stesso errore di “grant” menzionato in precedenza, aprirò un nuovo thread.

Grazie a tutti coloro che hanno aiutato finora. Almeno ora posso accedere al database. Un grande ringraziamento a tutti coloro che mi hanno aiutato ad arrivare fin qui.

MOLTO APPREZZATO!


== 20240611170904 UpgradePgvector070: migrating ===============================

I, [2025-11-02T15:17:02.281908 #1] INFO -- : Terminating async processes
I, [2025-11-02T15:17:02.282204 #1] INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U p
ostgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 2547
I, [2025-11-02T15:17:02.282450 #1] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 2644
2025-11-02 15:17:02.289 UTC [2547] LOG: received fast shutdown request
2644:signal-handler (1762096622) Received SIGTERM scheduling shutdown...
2644:M 02 Nov 2025 15:17:02.299 # User requested shutdown...
2644:M 02 Nov 2025 15:17:02.299 * Saving the final RDB snapshot before exiting.
2025-11-02 15:17:02.384 UTC [2547] LOG: aborting any active transactions
2025-11-02 15:17:02.391 UTC [2547] LOG: background worker \"logical replication launcher\" (PID 2562) exited with exit code 1
2025-11-02 15:17:02.452 UTC [2557] LOG: shutting down
2644:M 02 Nov 2025 15:17:02.549 * DB saved on disk
2644:M 02 Nov 2025 15:17:02.549 # Redis is now ready to exit, bye bye...
2025-11-02 15:17:06.304 UTC [2547] LOG: database system is shut down

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse &amp;&amp; sudo -E -u discourse bundle exec rake multisite:migrate failed with return #&lt;Process::Status: pid 4308
exit 1&gt;
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.3.0/lib/pups/exec_command.rb:131:inspawn’ exec failed with the params “cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate” bootstrap failed with exit code 1 ** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one. ./discourse-doctor may help diagnose the problem. `

EDIT: Ho trovato questo nei log. Non farò nulla finché non eseguirò doctor e cercherò gli errori.
2025-11-02 16:10:09.680 UTC [6244] postgres@c_discourse LOG: provided user name (postgres) and authenticated user name (discourse) do not match
2025-11-02 16:10:09.680 UTC [6244] postgres@c_discourse FATAL: Peer authentication failed for user "postgres"
2025-11-02 16:10:09.680 UTC [6244] postgres@c_discourse DETAIL: Connection matched pg_hba.conf line 89: "local all postgres
peer"

Per chiudere questa discussione, ho eseguito doctor e ho trovato l’errore alter. Poiché il database era in esecuzione, ho eseguito il comando alter sui database coinvolti nel multisite, ho rieseguito il build e ora sono stati migrati. L’accesso dell’utente al database persiste, ma aprirò un’altra discussione per questo.

Ancora grazie a tutti per avermi portato a questo punto.

Dato che li ho spostati come root ho dovuto fare chown e poi chmod ai file. Non li ho documentati ma l’output dell’errore lo indica.

Link al problema attuale.

Un post è stato unito a un argomento esistente: Problemi di accesso al database dopo l’aggiornamento v3.5.2 -\u003e v3.6.0.beta2