Sidekiq/Users::MigrateRecordsToGhostUserInBatchesWorker errors
@jessieay identified Sentry errors with the ghost user worker. We have had so far about 382k+ instances of these.
ActiveRecord::NotNullViolation
PG::NotNullViolation: ERROR: null value in column "author_id" of relation "vulnerabilities" violates not-null constraint
DETAIL: Failing row contains (125130534, 55560492, null, 2024-07-09 19:23:58.529357+00, 2024-07-31 19:34:46.178969+00, 1, 5, 2, f, f, zipp Denial of Service vulnerability, null, null, null, 1, null, null, null, null, null, null, null, f, t, null, 3048491504, [{"vector": "CVSS:3.0/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "ven...).
CONTEXT: SQL statement "UPDATE ONLY "public"."vulnerabilities" SET "author_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "author_id""
The issue may be due to a migration added around vulnerabilities author_ids that cannot be sell nullable once the author is deleted.A possible candidate may be the migration here but the issue needs investigation and confirmation of that.
The issue happens when the admin deletes the user record with delete with associated records option. In such cases associated records including vulnerability records should be deleted.
Edited by Aboobacker MK