PopulateForkNetworksRange error: ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: insert or update on table "fork_networks" violates foreign key c...
https://sentry.gitlap.com/gitlab/devgitlaborg/issues/72109/
PG::ForeignKeyViolation: ERROR: insert or update on table "fork_networks" violates foreign key constraint "fk_e7b436b2b5"
DETAIL: Key (root_project_id)=(185) is not present in table "projects".
lib/gitlab/background_migration/populate_fork_networks_range.rb:7:in `perform'
ActiveRecord::Base.connection.execute <<~INSERT_NETWORKS
lib/gitlab/background_migration.rb:49:in `perform'
const_get(class_name).new.perform(*arguments)
app/workers/background_migration_worker.rb:37:in `perform'
Gitlab::BackgroundMigration.perform(class_name, arguments)
lib/gitlab/sidekiq_status/server_middleware.rb:5:in `call'
ret = yield
lib/gitlab/sidekiq_middleware/request_store_middleware.rb:6:in `call'
yield
...
(41 additional frame(s) were not displayed)
ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: insert or update on table "fork_networks" violates foreign key constraint "fk_e7b436b2b5"
DETAIL: Key (root_project_id)=(185) is not present in table "projects".
: INSERT INTO fork_networks (root_project_id)
SELECT DISTINCT forked_project_links.forked_from_project_id
FROM forked_project_links
WHERE NOT EXISTS (
SELECT true
FROM forked_project_links inner_links
WHERE inner_links.forked_to_project_id = forked_project_links.forked_from_project_id
)
AND NOT EXISTS (
SELECT true
FROM fork_networks
WHERE forked_project_links.forked_from_project_id = fork_networks.root_project_id
)
AND forked_project_links.id BETWEEN 2 AND 78
PG::ForeignKeyViolation: ERROR: insert or update on table "fork_networks" violates foreign key constraint "fk_e7b436b2b5"
DETAIL: Key (root_project_id)=(185) is not present in table "projects".
: INSERT INTO fork_networks (root_project_id)
SELECT DISTINCT forked_project_links.forked_from_project_id
FROM forked_project_links
WHERE NOT EXISTS (
SELECT true
FROM forked_project_links inner_links
WHERE inner_links.forked_to_project_id = forked_project_links.forked_from_project_id
)
AND NOT EXISTS (
SELECT true
FROM fork_networks
WHERE forked_project_links.forked_from_project_id = fork_networks.root_project_id
)
AND forked_project_links.id BETWEEN 2 AND 78