Skip to content

Fix error in resource_events tables while deleting user

What does this MR do?

While investigating why user is not deleted while destroying an account, I discovered bug in Sentry - in resource events tables (3 of them) we are setting that user_id cannot be NULL, but in foreign key we are setting ON DELETE NULLIFY. This is causing an error.

I removed not null constraint from this tables.

Up:

== 20200609142506 RemoveNotNullConstraintFromWeightEventsTable: migrating ===========
-- change_column_null(:resource_weight_events, :user_id, true)
   -> 0.0003s
== 20200609142506 RemoveNotNullConstraintFromWeightEventsTable: migrated (0.0025s) ==
== 20200609142507 RemoveNotNullConstraintFromMilestoneEventsTable: migrating ===========
-- change_column_null(:resource_milestone_events, :user_id, true)
   -> 0.0012s
== 20200609142507 RemoveNotNullConstraintFromMilestoneEventsTable: migrated (0.0025s) ==
== 20200609142508 RemoveNotNullConstraintFromStateEventsTable: migrating ===========
-- change_column_null(:resource_state_events, :user_id, true)
   -> 0.0008s
== 20200609142508 RemoveNotNullConstraintFromStateEventsTable: migrated (0.0025s) ==

Down:

== 20200609142506 RemoveNotNullConstraintFromWeightEventsTable: reverting ===========
-- change_column_null(:resource_weight_events, :user_id, false)
   -> 0.0017s
== 20200609142506 RemoveNotNullConstraintFromWeightEventsTable: reverted (0.0061s) ==
== 20200609142507 RemoveNotNullConstraintFromMilestoneEventsTable: reverting ===========
-- change_column_null(:resource_milestone_events, :user_id, false)
   -> 0.0015s
== 20200609142507 RemoveNotNullConstraintFromMilestoneEventsTable: reverted (0.0061s) ==
== 20200609142508 RemoveNotNullConstraintFromStateEventsTable: reverting ===========
-- change_column_null(:resource_state_events, :user_id, false)
   -> 0.0010s
== 20200609142508 RemoveNotNullConstraintFromStateEventsTable: reverted (0.0061s) ==

Does this MR meet the acceptance criteria?

https://sentry.gitlab.net/gitlab/gitlabcom/issues/1635101/?query=is%3Aunresolved%20DeleteUserWorker

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Gosia Ksionek

Merge request reports

Loading