Major upgrade from 14.8 to 15.5 fail during pg_restore command
Hi, I tried to upgrade Postgres version from 14.8 to 15.5 through the Web console with database operation.
The process fails during the initialization task named “major-version-upgrade” (Init:5/7).
It’s look like the error is raised during the execution of this command "/usr/lib/postgresql/15.5/bin/pg_restore" --host /var/lib/postgresql/upgrade/15.5 --port 50432 --username postgres --create --exit-on-error --verbose --dbname template1 "/var/lib/postgresql/upgrade/15.5/data/pg_upgrade_output.d/20240313T145818.353/dump/pg_upgrade_dump_184017.custom" >> "/var/lib/postgresql/upgrade/15.5/data/pg_upgrade_output.d/20240313T145818.353/log/pg_upgrade_dump_184017.log" 2>&1
And the error is pg_restore: error: could not execute query: ERROR: role "37512" does not exist.
the faulty database use postgis and postgis_topology extensions (I don’t know if it really matters ?)
I think the faulty part is this one
--
-- Name: TABLE "spatial_ref_sys"; Type: ACL; Schema: public; Owner: postgres
--
SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);
REVOKE ALL ON TABLE "public"."spatial_ref_sys" FROM "postgres";
SET SESSION AUTHORIZATION "37512";
GRANT ALL ON TABLE "public"."spatial_ref_sys" TO "37512";
RESET SESSION AUTHORIZATION;
SET SESSION AUTHORIZATION "37512";
GRANT SELECT ON TABLE "public"."spatial_ref_sys" TO PUBLIC;
RESET SESSION AUTHORIZATION;
SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);
REVOKE ALL ON TABLE "public"."spatial_ref_sys" FROM "37512";
REVOKE SELECT ON TABLE "public"."spatial_ref_sys" FROM PUBLIC;
GRANT ALL ON TABLE "public"."spatial_ref_sys" TO "postgres";
GRANT SELECT ON TABLE "public"."spatial_ref_sys" TO PUBLIC;
Content of /var/lib/postgresql/upgrade/15.5/data/pg_upgrade_output.d/20240313x/log/pg_upgrade_internal.log:
-----------------------------------------------------------------
pg_upgrade run on Wed Mar 13 14:58:18 2024
-----------------------------------------------------------------
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is the install user ok
Checking database connection settings ok
Checking for prepared transactions ok
Checking for system-defined composite types in user tables ok
Checking for reg* data types in user tables ok
Checking for contrib/isn with bigint-passing mismatch ok
Creating dump of global objects ok
Creating dump of database schemas ok
Checking for presence of required libraries ok
Checking database user is the install user ok
Checking for prepared transactions ok
Checking for new cluster tablespace directories ok
If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.
Performing Upgrade
------------------
Analyzing all rows in the new cluster ok
Freezing all rows in the new cluster ok
Deleting files from new pg_xact ok
Copying old pg_xact to new server ok
Setting oldest XID for new cluster ok
Setting next transaction ID and epoch for new cluster ok
Deleting files from new pg_multixact/offsets ok
Copying old pg_multixact/offsets to new server ok
Deleting files from new pg_multixact/members ok
Copying old pg_multixact/members to new server ok
Setting next multixact ID and offset for new cluster ok
Resetting WAL archives ok
Setting frozenxid and minmxid counters in new cluster ok
Restoring global objects in the new cluster ok
Restoring database schemas in the new cluster
*failure*
Consult the last few lines of "/var/lib/postgresql/upgrade/15.5/data/pg_upgrade_output.d/20240313x/log/pg_upgrade_dump_184017.log" for
the probable cause of the failure.
End of /var/lib/postgresql/upgrade/15.5/data/pg_upgrade_output.d/20240313x/log/pg_upgrade_server.log:
2024-03-13 14:58:55 UTC [803]: db=[unknown],user=[unknown],app=[unknown],client=[local] LOG: connection received: host=[local]
2024-03-13 14:58:55 UTC [803]: db=db_using_postgis,user=postgres,app=[unknown],client=[local] LOG: connection authorized: user=postgres database=db_using_postgis application_name=pg_restore
2024-03-13 14:58:55 UTC [790]: db=template1,user=postgres,app=pg_restore,client=[local] LOG: disconnection: session time: 0:00:01.701 user=postgres database=template1 host=[local]
2024-03-13 14:58:55 UTC [804]: db=[unknown],user=[unknown],app=[unknown],client=[local] LOG: connection received: host=[local]
2024-03-13 14:58:55 UTC [804]: db=db_using_postgis,user=postgres,app=[unknown],client=[local] LOG: connection authorized: user=postgres database=db_using_postgis application_name=pg_restore
2024-03-13 14:58:55 UTC [803]: db=db_using_postgis,user=postgres,app=pg_restore,client=[local] LOG: disconnection: session time: 0:00:00.036 user=postgres database=db_using_postgis host=[local]
2024-03-13 14:58:56 UTC [804]: db=db_using_postgis,user=postgres,app=pg_restore,client=[local] ERROR: role "37512" does not exist
2024-03-13 14:58:56 UTC [804]: db=db_using_postgis,user=postgres,app=pg_restore,client=[local] STATEMENT: SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);
REVOKE ALL ON TABLE "public"."geography_columns" FROM "postgres";
SET SESSION AUTHORIZATION "37512";
GRANT ALL ON TABLE "public"."geography_columns" TO "37512";
RESET SESSION AUTHORIZATION;
SET SESSION AUTHORIZATION "37512";
GRANT SELECT ON TABLE "public"."geography_columns" TO PUBLIC;
RESET SESSION AUTHORIZATION;
SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);
REVOKE ALL ON TABLE "public"."geography_columns" FROM "37512";
REVOKE SELECT ON TABLE "public"."geography_columns" FROM PUBLIC;
GRANT ALL ON TABLE "public"."geography_columns" TO "postgres";
GRANT SELECT ON TABLE "public"."geography_columns" TO PUBLIC;
2024-03-13 14:58:56 UTC [804]: db=db_using_postgis,user=postgres,app=pg_restore,client=[local] LOG: disconnection: session time: 0:00:00.891 user=postgres database=db_using_postgis host=[local]
command: "/usr/lib/postgresql/15.5/bin/pg_ctl" -w -D "/var/lib/postgresql/upgrade/15.5/data" -o "-c 'dynamic_library_path=/usr/lib/postgresql/15.5/lib:/usr/lib/postgresql/15.5/extra/lib'" -m fast stop >> "/var/lib/postgresql/upgrade/15.5/data/pg_upgrade_output.d/20240313x/log/pg_upgrade_server.log" 2>&1
waiting for server to shut down...2024-03-13 14:58:56 UTC [588]: db=,user=,app=,client= LOG: received fast shutdown request
.2024-03-13 14:58:56 UTC [588]: db=,user=,app=,client= LOG: aborting any active transactions
2024-03-13 14:58:56 UTC [588]: db=,user=,app=,client= LOG: background worker "logical replication launcher" (PID 593) exited with exit code 1
2024-03-13 14:58:56 UTC [589]: db=,user=,app=,client= LOG: shutting down
2024-03-13 14:58:56 UTC [589]: db=,user=,app=,client= LOG: checkpoint starting: shutdown immediate
......2024-03-13 14:59:03 UTC [589]: db=,user=,app=,client= LOG: checkpoint complete: wrote 12534 buffers (76.5%); 0 WAL file(s) added, 0 removed, 0 recycled; write=6.817 s, sync=0.001 s, total=6.833 s; sync files=0, longest=0.000 s, average=0.000 s; distance=62384 kB, estimate=62384 kB
...2024-03-13 14:59:06 UTC [588]: db=,user=,app=,client= LOG: database system is shut down
done
server stopped
Please, tell me if you need any other information. I'm a bit lost...