Gitlab version: 17.8.4
Postgres version: 14
- We see errors in postgresql log file:
2025-03-17T09:26:03.989457+00:00 xxx WARNING [17-1] pgpid=1965323 pgapp=/opt/gitlab/embedded/lib/ruby/gems/3.2.0/bin/sidekiq ERROR: null value in column “user_id” of relation “resource_link_events” violates not-null constraint
2025-03-17T09:26:03.989936+00:00 xxx WARNING [17-2] pgpid=1965323 pgapp=/opt/gitlab/embedded/lib/ruby/gems/3.2.0/bin/sidekiq DETAIL: Failing row contains (659, 1, null, 30421, 33773, 2023-09-18 09:23:58.931884+00, 146945, 2676).
2025-03-17T09:26:03.990009+00:00 xxx WARNING [17-3] pgpid=1965323 pgapp=/opt/gitlab/embedded/lib/ruby/gems/3.2.0/bin/sidekiq CONTEXT: SQL statement “UPDATE ONLY “public”.“resource_link_events” SET “user_id” = NULL WHERE $1 OPERATOR(pg_catalog.=) “user_id””
2025-03-17T09:26:03.990058+00:00 xxx WARNING [17-4] pgpid=1965323 pgapp=/opt/gitlab/embedded/lib/ruby/gems/3.2.0/bin/sidekiq STATEMENT: /application:sidekiq,correlation_id:45b53ef60f6a113b1151cdabf52e807d,jid:742ea0411ff19e4146075a6d,endpoint_id:Users::MigrateRecordsToGhostUserInBatchesWorker,db_config_database:gitlab,db_config_name:main/ DELETE FROM “users” WHERE “users”.“id” = 608
-
Rows for user_id=608 exist in “users” , “resource_link_events” and in “ghost_user_migrations” tables.
-
Definition of table resource_link_events have user_id NOT NULL, and a constraint saying “ON DELETE SET NULL”.
CREATE TABLE IF NOT EXISTS public.resource_link_events
(
id bigint NOT NULL DEFAULT nextval(‘resource_link_events_id_seq’::regclass),
action smallint NOT NULL,
user_id bigint NOT NULL,
issue_id bigint NOT NULL,
child_work_item_id bigint NOT NULL,
…
…
CONSTRAINT fk_bd4ae15ce4 FOREIGN KEY (user_id)
REFERENCES public.users (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE SET NULL,
- Every minute when cron job “users_migrate_records_to_ghost_user_in_batches_worker” runs, the “updated at” column in table ghost_user_migrations are updated with latest timestamp.
“id”
“user_id”
“initiator_user_id”
“created_at”
“updated_at”
“hard_delete”
“consume_after”
228
608
1131
“2024-11-15 13:52:05.356706+00”
“2025-03-17 14:30:03.465013+00”
false
“2025-03-17 15:00:03.464376+00”
Can anyone please help us how to fix this issue?