Migration error

Hello,

I’m trying to upgrade my GVM instance but it seems I got an error.

I upgraded the compose file, pull the containers but when the migrator container runs, it ends with error.

pg-gvm-migrator-1 | Performing Upgrade
pg-gvm-migrator-1 | ------------------
pg-gvm-migrator-1 | Setting locale and encoding for new cluster ok
pg-gvm-migrator-1 | Analyzing all rows in the new cluster ok
pg-gvm-migrator-1 | Freezing all rows in the new cluster ok
pg-gvm-migrator-1 | Deleting files from new pg_xact ok
pg-gvm-migrator-1 | Copying old pg_xact to new server ok
pg-gvm-migrator-1 | Setting oldest XID for new cluster ok
pg-gvm-migrator-1 | Setting next transaction ID and epoch for new cluster ok
pg-gvm-migrator-1 | Deleting files from new pg_multixact/offsets ok
pg-gvm-migrator-1 | Copying old pg_multixact/offsets to new server ok
pg-gvm-migrator-1 | Deleting files from new pg_multixact/members ok
pg-gvm-migrator-1 | Copying old pg_multixact/members to new server ok
pg-gvm-migrator-1 | Setting next multixact ID and offset for new cluster ok
pg-gvm-migrator-1 | Resetting WAL archives ok
pg-gvm-migrator-1 | Setting frozenxid and minmxid counters in new cluster ok
pg-gvm-migrator-1 | Restoring global objects in the new cluster ok
pg-gvm-migrator-1 | Restoring database schemas in the new cluster
pg-gvm-migrator-1 | *failure*
pg-gvm-migrator-1 |
pg-gvm-migrator-1 | Consult the last few lines of “/var/lib/postgresql/17/main/pg_upgrade_output.d/20260129T111243.609/log/pg_upgrade_
dump_16385.log” for
pg-gvm-migrator-1 | the probable cause of the failure.
pg-gvm-migrator-1 | Failure, exiting
pg-gvm-migrator-1 | ERROR: pg_upgrade failed.
pg-gvm-migrator-1 exited with code 1

I changed the tag of pg-gvm to 22.6.10, removed dependency and also removed the container pg-gvm-migrator to restart my instance.

When I check the log file, it ends with:

pg_restore: creating FK CONSTRAINT “public.report_configs_trash report_configs_trash_owner_fkey”
pg_restore: creating FK CONSTRAINT “public.report_counts report_counts_report_fkey”
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 4621; 2606 85225 FK CONSTRAINT report_counts report_counts_report_fkey gvmd
pg_restore: error: could not execute query: ERROR: there is no unique constraint matching given keys for referenced table “reports”
Command was: ALTER TABLE ONLY “public”.“report_counts”
ADD CONSTRAINT “report_counts_report_fkey” FOREIGN KEY (“report”) REFERENCES “public”.“reports”(“id”) ON DELETE RESTRICT;

What can I do ?

Thanks

Hi,

sadly your database is inconsistent for some unknown reasons. It seems there are duplicate entries for the report_id in the report_counts table. It is a 1:1 relationship but two report count entries point to the same report.

Thanks for the quick answer,

I have a backup of the database so I can test.

I removed all the reports I had through the web interface using the tag 22.6.10 and now I don’t have anything anymore on report_counts table:
gvmd=# select * from report_counts;
id | report | user | severity | count | override | end_time | min_qod
----±-------±-----±---------±------±---------±---------±--------
(0 rows)

I removed also the 17 directory created during the migration.

I also checked and the column id in the reports table is a PRIMARY KEY

Restarting the migration gave the same error :smiling_face_with_tear:

Could you paste the whole error log from the pg-gvm-migrator container? maybe that gives us another hint.

Sorry, I can’t do it anymore. I tried to restore a backup of the DB and I had a lot of errors so I exported all what I was able to export from the UI, reinstalled everything and import/recreate what I was able to. I didn’t have a lot of targets/tasks/…

This is not a very good solution (this won’t help people in case they have the same issue) but the DB should be OK now.