Deleting user fails while setting author_id in the database
Summary
When a user attempted to delete their user account to re-use an email address. However, the deletion failed and the user just became blocked and stalled out during this process. I changed the email address and appended _old so they can re-use their email address. However, we should still delete their user old account. I tried deleting it via Admin but it timed out.
Steps to reproduce
Example Project
- Details can be found in this issue. (internal)
- Kibana: https://log.gprd.gitlab.net/goto/3db3c5e0-b065-11ec-b73f-692cc1ae8214 (internal)
- Zendesk: https://gitlab.zendesk.com/agent/tickets/277846 (internal)
What is the current bug behavior?
- When a user tries to remove his account, it fails.
- It fails even when trying to remove from the admin area.
- It also fails when we test the same from console.
What is the expected correct behavior?
- It should delete the user.
Relevant logs and/or screenshots
Error log
[ gprd ] production> Users::DestroyService.new(User.find_by_username('ADMINUSER')).execute(u)
D, [2022-03-31T11:20:32.323280 #3413723] DEBUG -- : User Load (1.9ms) /*application:console,db_config_name:main*/ SELECT "users".* FROM "users" WHERE (LOWER("users"."username") IN (LOWER('TKMA4CU'))) LIMIT 1
D, [2022-03-31T11:20:32.333947 #3413723] DEBUG -- : Member Load (1.6ms) /*application:console,db_config_name:main*/ SELECT "members".* FROM "members" WHERE "members"."user_id" = 8306233 ORDER BY "members"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.339501 #3413723] DEBUG -- : Project Load (1.7ms) /*application:console,db_config_name:main*/ SELECT "projects"."id", "projects"."name", "projects"."path", "projects"."description", "projects"."created_at", "projects"."updated_at", "projects"."creator_id", "projects"."namespace_id", "projects"."last_activity_at", "projects"."import_url", "projects"."visibility_level", "projects"."archived", "projects"."merge_requests_template", "projects"."star_count", "projects"."merge_requests_rebase_enabled", "projects"."import_type", "projects"."import_source", "projects"."avatar", "projects"."approvals_before_merge", "projects"."reset_approvals_on_push", "projects"."merge_requests_ff_only_enabled", "projects"."issues_template", "projects"."mirror", "projects"."mirror_user_id", "projects"."shared_runners_enabled", "projects"."runners_token", "projects"."build_coverage_regex", "projects"."build_allow_git_fetch", "projects"."build_timeout", "projects"."mirror_trigger_builds", "projects"."public_builds", "projects"."pending_delete", "projects"."last_repository_check_failed", "projects"."last_repository_check_at", "projects"."only_allow_merge_if_pipeline_succeeds", "projects"."has_external_issue_tracker", "projects"."repository_storage", "projects"."request_access_enabled", "projects"."has_external_wiki", "projects"."repository_read_only", "projects"."lfs_enabled", "projects"."description_html", "projects"."only_allow_merge_if_all_discussions_are_resolved", "projects"."repository_size_limit", "projects"."service_desk_enabled", "projects"."printing_merge_request_link_enabled", "projects"."auto_cancel_pending_pipelines", "projects"."cached_markdown_version", "projects"."last_repository_updated_at", "projects"."ci_config_path", "projects"."disable_overriding_approvers_per_merge_request", "projects"."delete_error", "projects"."storage_version", "projects"."resolve_outdated_diff_discussions", "projects"."remote_mirror_available_overridden", "projects"."only_mirror_protected_branches", "projects"."pull_mirror_available_overridden", "projects"."jobs_cache_index", "projects"."external_authorization_classification_label", "projects"."mirror_overwrites_diverged_branches", "projects"."external_webhook_token", "projects"."pages_https_only", "projects"."packages_enabled", "projects"."merge_requests_author_approval", "projects"."pool_repository_id", "projects"."runners_token_encrypted", "projects"."bfg_object_map", "projects"."detected_repository_languages", "projects"."merge_requests_disable_committers_approval", "projects"."require_password_to_approve", "projects"."emails_disabled", "projects"."max_pages_size", "projects"."max_artifacts_size", "projects"."remove_source_branch_after_merge", "projects"."marked_for_deletion_at", "projects"."marked_for_deletion_by_user_id", "projects"."suggestion_commit_message", "projects"."autoclose_referenced_issues", "projects"."project_namespace_id", "projects"."hidden" FROM "projects" WHERE "projects"."mirror_user_id" = 8306233 ORDER BY "projects"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.345569 #3413723] DEBUG -- : IncidentManagement::OncallRotation Load (1.1ms) /*application:console,db_config_name:main*/ SELECT "incident_management_oncall_rotations".* FROM "incident_management_oncall_rotations" INNER JOIN "incident_management_oncall_participants" ON "incident_management_oncall_rotations"."id" = "incident_management_oncall_participants"."oncall_rotation_id" WHERE "incident_management_oncall_participants"."user_id" = 8306233 AND "incident_management_oncall_participants"."is_removed" = FALSE
D, [2022-03-31T11:20:32.348360 #3413723] DEBUG -- : IncidentManagement::EscalationRule Load (0.7ms) /*application:console,db_config_name:main*/ SELECT "incident_management_escalation_rules".* FROM "incident_management_escalation_rules" WHERE "incident_management_escalation_rules"."user_id" = 8306233
D, [2022-03-31T11:20:32.350314 #3413723] DEBUG -- : IncidentManagement::EscalationRule Destroy (0.6ms) /*application:console,db_config_name:main*/ DELETE FROM "incident_management_escalation_rules" WHERE 1=0
D, [2022-03-31T11:20:32.352781 #3413723] DEBUG -- : User Load (1.1ms) /*application:console,db_config_name:main*/ SELECT "users".* FROM "users" WHERE "users"."user_type" = 5 ORDER BY "users"."id" ASC LIMIT 1
D, [2022-03-31T11:20:32.364699 #3413723] DEBUG -- : TRANSACTION (0.5ms) /*application:console,db_config_name:main*/ BEGIN
D, [2022-03-31T11:20:32.366745 #3413723] DEBUG -- : ResourceIterationEvent Load (1.6ms) /*application:console,db_config_name:main*/ SELECT "resource_iteration_events"."id" FROM "resource_iteration_events" WHERE "resource_iteration_events"."user_id" = 8306233 ORDER BY "resource_iteration_events"."id" ASC LIMIT 1
D, [2022-03-31T11:20:32.370139 #3413723] DEBUG -- : Epic Update All (1.2ms) /*application:console,db_config_name:main*/ UPDATE "epics" SET "author_id" = 1243277 WHERE "epics"."id" IN (SELECT "epics"."id" FROM "epics" WHERE "epics"."author_id" = 8306233 LIMIT 100)
D, [2022-03-31T11:20:32.373154 #3413723] DEBUG -- : Epic Update All (1.7ms) /*application:console,db_config_name:main*/ UPDATE "epics" SET "last_edited_by_id" = 1243277 WHERE "epics"."id" IN (SELECT "epics"."id" FROM "epics" WHERE "epics"."last_edited_by_id" = 8306233 LIMIT 100)
D, [2022-03-31T11:20:32.375992 #3413723] DEBUG -- : RequirementsManagement::Requirement Update All (1.2ms) /*application:console,db_config_name:main*/ UPDATE "requirements" SET "author_id" = 1243277 WHERE "requirements"."author_id" = 8306233
D, [2022-03-31T11:20:32.380532 #3413723] DEBUG -- : Vulnerabilities::Feedback Update All (2.8ms) /*application:console,db_config_name:main*/ UPDATE "vulnerability_feedback" SET "author_id" = 1243277 WHERE "vulnerability_feedback"."author_id" = 8306233
D, [2022-03-31T11:20:32.383782 #3413723] DEBUG -- : Vulnerabilities::Feedback Update All (0.9ms) /*application:console,db_config_name:main*/ UPDATE "vulnerability_feedback" SET "comment_author_id" = 1243277 WHERE "vulnerability_feedback"."comment_author_id" = 8306233
D, [2022-03-31T11:20:32.386896 #3413723] DEBUG -- : Issue Update All (1.5ms) /*application:console,db_config_name:main*/ UPDATE "issues" SET "author_id" = 1243277 WHERE "issues"."id" IN (SELECT "issues"."id" FROM "issues" WHERE "issues"."author_id" = 8306233 LIMIT 100)
D, [2022-03-31T11:20:32.389960 #3413723] DEBUG -- : Issue Update All (1.9ms) /*application:console,db_config_name:main*/ UPDATE "issues" SET "last_edited_by_id" = 1243277 WHERE "issues"."id" IN (SELECT "issues"."id" FROM "issues" WHERE "issues"."last_edited_by_id" = 8306233 LIMIT 100)
D, [2022-03-31T11:20:32.392715 #3413723] DEBUG -- : MergeRequest Update All (1.2ms) /*application:console,db_config_name:main*/ UPDATE "merge_requests" SET "author_id" = 1243277 WHERE "merge_requests"."id" IN (SELECT "merge_requests"."id" FROM "merge_requests" WHERE "merge_requests"."author_id" = 8306233 LIMIT 100)
D, [2022-03-31T11:20:32.395331 #3413723] DEBUG -- : MergeRequest Update All (1.3ms) /*application:console,db_config_name:main*/ UPDATE "merge_requests" SET "merge_user_id" = 1243277 WHERE "merge_requests"."id" IN (SELECT "merge_requests"."id" FROM "merge_requests" WHERE "merge_requests"."merge_user_id" = 8306233 LIMIT 100)
D, [2022-03-31T11:20:32.398431 #3413723] DEBUG -- : Note Update All (1.3ms) /*application:console,db_config_name:main*/ UPDATE "notes" SET "author_id" = 1243277 WHERE "notes"."id" IN (SELECT "notes"."id" FROM "notes" WHERE "notes"."author_id" = 8306233 LIMIT 100)
D, [2022-03-31T11:20:32.400755 #3413723] DEBUG -- : AbuseReport Update All (0.9ms) /*application:console,db_config_name:main*/ UPDATE "abuse_reports" SET "reporter_id" = 1243277 WHERE "abuse_reports"."reporter_id" = 8306233
D, [2022-03-31T11:20:32.402674 #3413723] DEBUG -- : AwardEmoji Update All (0.7ms) /*application:console,db_config_name:main*/ UPDATE "award_emoji" SET "user_id" = 1243277 WHERE "award_emoji"."user_id" = 8306233
D, [2022-03-31T11:20:32.406272 #3413723] DEBUG -- : Snippet Update All (2.2ms) /*application:console,db_config_name:main*/ UPDATE "snippets" SET "author_id" = 1243277 WHERE "snippets"."author_id" = 8306233 AND "snippets"."project_id" IS NOT NULL
D, [2022-03-31T11:20:32.409436 #3413723] DEBUG -- : Review Update All (1.9ms) /*application:console,db_config_name:main*/ UPDATE "reviews" SET "author_id" = 1243277 WHERE "reviews"."id" IN (SELECT "reviews"."id" FROM "reviews" WHERE "reviews"."author_id" = 8306233 LIMIT 100)
D, [2022-03-31T11:20:32.411187 #3413723] DEBUG -- : TRANSACTION (0.7ms) /*application:console,db_config_name:main*/ COMMIT
D, [2022-03-31T11:20:32.414258 #3413723] DEBUG -- : User Load (1.1ms) /*application:console,db_config_name:main*/ SELECT "users".* FROM "users" WHERE "users"."id" = 8306233 LIMIT 1
D, [2022-03-31T11:20:32.418029 #3413723] DEBUG -- : Snippet Exists? (1.3ms) /*application:console,db_config_name:main*/ SELECT 1 AS one FROM "snippets" WHERE "snippets"."author_id" = 8306233 LIMIT 1
D, [2022-03-31T11:20:32.422495 #3413723] DEBUG -- : Key Load (1.8ms) /*application:console,db_config_name:main*/ SELECT "keys".* FROM "keys" WHERE "keys"."user_id" = 8306233 AND ("keys"."type" IN ('LDAPKey', 'Key') OR "keys"."type" IS NULL) ORDER BY "keys"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.425645 #3413723] DEBUG -- : PersonalAccessToken Load (0.9ms) /*application:console,db_config_name:main*/ SELECT "personal_access_tokens".* FROM "personal_access_tokens" WHERE "personal_access_tokens"."user_id" = 8306233 ORDER BY "personal_access_tokens"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.429732 #3413723] DEBUG -- : Identity Load (0.7ms) /*application:console,db_config_name:main*/ SELECT "identities".* FROM "identities" WHERE "identities"."user_id" = 8306233 ORDER BY "identities"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.433471 #3413723] DEBUG -- : U2fRegistration Load (1.5ms) /*application:console,db_config_name:main*/ SELECT "u2f_registrations".* FROM "u2f_registrations" WHERE "u2f_registrations"."user_id" = 8306233 ORDER BY "u2f_registrations"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.436809 #3413723] DEBUG -- : ChatName Load (1.2ms) /*application:console,db_config_name:main*/ SELECT "chat_names".* FROM "chat_names" WHERE "chat_names"."user_id" = 8306233 ORDER BY "chat_names"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.439647 #3413723] DEBUG -- : UsersStarProject Load (1.2ms) /*application:console,db_config_name:main*/ SELECT "users_star_projects".* FROM "users_star_projects" WHERE "users_star_projects"."user_id" = 8306233 ORDER BY "users_star_projects"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.442623 #3413723] DEBUG -- : Note Load (1.3ms) /*application:console,db_config_name:main*/ SELECT "notes".* FROM "notes" WHERE "notes"."author_id" = 8306233 ORDER BY "notes"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.446006 #3413723] DEBUG -- : Issue Load (1.1ms) /*application:console,db_config_name:main*/ SELECT "issues".* FROM "issues" WHERE "issues"."author_id" = 8306233 ORDER BY "issues"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.448776 #3413723] DEBUG -- : MergeRequest Load (1.0ms) /*application:console,db_config_name:main*/ SELECT "merge_requests".* FROM "merge_requests" WHERE "merge_requests"."author_id" = 8306233 ORDER BY "merge_requests"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.520514 #3413723] DEBUG -- : Subscription Load (69.9ms) /*application:console,db_config_name:main*/ SELECT "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."user_id" = 8306233 ORDER BY "subscriptions"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.523353 #3413723] DEBUG -- : Doorkeeper::Application Load (0.8ms) /*application:console,db_config_name:main*/ SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."owner_id" = 8306233 AND "oauth_applications"."owner_type" = 'User' ORDER BY "oauth_applications"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.526229 #3413723] DEBUG -- : AbuseReport Load (1.2ms) /*application:console,db_config_name:main*/ SELECT "abuse_reports".* FROM "abuse_reports" WHERE "abuse_reports"."reporter_id" = 8306233 ORDER BY "abuse_reports"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.530191 #3413723] DEBUG -- : SpamLog Load (1.6ms) /*application:console,db_config_name:main*/ SELECT "spam_logs".* FROM "spam_logs" WHERE "spam_logs"."user_id" = 8306233 ORDER BY "spam_logs"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.533167 #3413723] DEBUG -- : AwardEmoji Load (0.7ms) /*application:console,db_config_name:main*/ SELECT "award_emoji".* FROM "award_emoji" WHERE "award_emoji"."user_id" = 8306233 ORDER BY "award_emoji"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.535658 #3413723] DEBUG -- : PathLock Load (0.9ms) /*application:console,db_config_name:main*/ SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."user_id" = 8306233 ORDER BY "path_locks"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.537967 #3413723] DEBUG -- : Approval Load (0.8ms) /*application:console,db_config_name:main*/ SELECT "approvals".* FROM "approvals" WHERE "approvals"."user_id" = 8306233 ORDER BY "approvals"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.540243 #3413723] DEBUG -- : Approver Load (0.8ms) /*application:console,db_config_name:main*/ SELECT "approvers".* FROM "approvers" WHERE "approvers"."user_id" = 8306233 ORDER BY "approvers"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.542502 #3413723] DEBUG -- : ProtectedBranch::MergeAccessLevel Load (0.8ms) /*application:console,db_config_name:main*/ SELECT "protected_branch_merge_access_levels".* FROM "protected_branch_merge_access_levels" WHERE "protected_branch_merge_access_levels"."user_id" = 8306233 ORDER BY "protected_branch_merge_access_levels"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.544955 #3413723] DEBUG -- : ProtectedBranch::PushAccessLevel Load (0.9ms) /*application:console,db_config_name:main*/ SELECT "protected_branch_push_access_levels".* FROM "protected_branch_push_access_levels" WHERE "protected_branch_push_access_levels"."user_id" = 8306233 ORDER BY "protected_branch_push_access_levels"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.547805 #3413723] DEBUG -- : ProtectedBranch::UnprotectAccessLevel Load (1.0ms) /*application:console,db_config_name:main*/ SELECT "protected_branch_unprotect_access_levels".* FROM "protected_branch_unprotect_access_levels" WHERE "protected_branch_unprotect_access_levels"."user_id" = 8306233 ORDER BY "protected_branch_unprotect_access_levels"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.551720 #3413723] DEBUG -- : TRANSACTION (0.5ms) /*application:console,db_config_name:main*/ BEGIN
D, [2022-03-31T11:20:32.552941 #3413723] DEBUG -- : Upload Load (0.8ms) /*application:console,db_config_name:main*/ SELECT "uploads".* FROM "uploads" WHERE "uploads"."model_id" = 8306233 AND "uploads"."model_type" = 'User' AND "uploads"."uploader" IN ('PersonalFileUploader', 'NamespaceFileUploader', 'FileUploader') AND "uploads"."store" = 1 ORDER BY "uploads"."id" ASC LIMIT 1000
D, [2022-03-31T11:20:32.554973 #3413723] DEBUG -- : (0.7ms) /*application:console,db_config_name:main*/ SELECT "uploads"."path" FROM "uploads" WHERE "uploads"."model_id" = 8306233 AND "uploads"."model_type" = 'User' AND "uploads"."uploader" IN ('PersonalFileUploader', 'NamespaceFileUploader', 'FileUploader') AND "uploads"."store" = 2
D, [2022-03-31T11:20:32.556825 #3413723] DEBUG -- : Upload Destroy (0.7ms) /*application:console,db_config_name:main*/ DELETE FROM "uploads" WHERE "uploads"."model_id" = 8306233 AND "uploads"."model_type" = 'User' AND "uploads"."uploader" IN ('PersonalFileUploader', 'NamespaceFileUploader', 'FileUploader')
D, [2022-03-31T11:20:32.559720 #3413723] DEBUG -- : Namespace Load (1.0ms) /*application:console,db_config_name:main*/ SELECT "namespaces"."id", "namespaces"."name", "namespaces"."path", "namespaces"."owner_id", "namespaces"."created_at", "namespaces"."updated_at", "namespaces"."type", "namespaces"."description", "namespaces"."avatar", "namespaces"."membership_lock", "namespaces"."share_with_group_lock", "namespaces"."visibility_level", "namespaces"."request_access_enabled", "namespaces"."ldap_sync_status", "namespaces"."ldap_sync_error", "namespaces"."ldap_sync_last_update_at", "namespaces"."ldap_sync_last_successful_update_at", "namespaces"."ldap_sync_last_sync_at", "namespaces"."lfs_enabled", "namespaces"."description_html", "namespaces"."parent_id", "namespaces"."shared_runners_minutes_limit", "namespaces"."repository_size_limit", "namespaces"."require_two_factor_authentication", "namespaces"."two_factor_grace_period", "namespaces"."cached_markdown_version", "namespaces"."project_creation_level", "namespaces"."runners_token", "namespaces"."file_template_project_id", "namespaces"."saml_discovery_token", "namespaces"."runners_token_encrypted", "namespaces"."custom_project_templates_group_id", "namespaces"."auto_devops_enabled", "namespaces"."extra_shared_runners_minutes_limit", "namespaces"."last_ci_minutes_notification_at", "namespaces"."last_ci_minutes_usage_notification_level", "namespaces"."subgroup_creation_level", "namespaces"."emails_disabled", "namespaces"."max_pages_size", "namespaces"."max_artifacts_size", "namespaces"."mentions_disabled", "namespaces"."default_branch_protection", "namespaces"."unlock_membership_to_ldap", "namespaces"."max_personal_access_token_lifetime", "namespaces"."push_rule_id", "namespaces"."shared_runners_enabled", "namespaces"."allow_descendants_override_disabled_shared_runners", "namespaces"."traversal_ids" FROM "namespaces" WHERE "namespaces"."owner_id" = 8306233 AND "namespaces"."type" = 'User' LIMIT 1
D, [2022-03-31T11:20:32.574197 #3413723] DEBUG -- : (1.2ms) /*application:console,db_config_name:main*/ SELECT distinct(repository_storage) FROM "projects" WHERE "projects"."namespace_id" = 11150859 AND ("projects"."storage_version" < 1 OR "projects"."storage_version" IS NULL)
D, [2022-03-31T11:20:32.577927 #3413723] DEBUG -- : Route Load (1.8ms) /*application:console,db_config_name:main*/ SELECT "routes".* FROM "routes" WHERE "routes"."source_id" = 11150859 AND "routes"."source_type" = 'Namespace' LIMIT 1
D, [2022-03-31T11:20:32.579979 #3413723] DEBUG -- : Route Destroy (0.7ms) /*application:console,db_config_name:main*/ DELETE FROM "routes" WHERE "routes"."id" = 35068004
D, [2022-03-31T11:20:32.582809 #3413723] DEBUG -- : RedirectRoute Load (1.5ms) /*application:console,db_config_name:main*/ SELECT "redirect_routes".* FROM "redirect_routes" WHERE "redirect_routes"."source_id" = 11150859 AND "redirect_routes"."source_type" = 'Namespace'
D, [2022-03-31T11:20:32.586129 #3413723] DEBUG -- : Project Load (1.5ms) /*application:console,db_config_name:main*/ SELECT "projects"."id", "projects"."name", "projects"."path", "projects"."description", "projects"."created_at", "projects"."updated_at", "projects"."creator_id", "projects"."namespace_id", "projects"."last_activity_at", "projects"."import_url", "projects"."visibility_level", "projects"."archived", "projects"."merge_requests_template", "projects"."star_count", "projects"."merge_requests_rebase_enabled", "projects"."import_type", "projects"."import_source", "projects"."avatar", "projects"."approvals_before_merge", "projects"."reset_approvals_on_push", "projects"."merge_requests_ff_only_enabled", "projects"."issues_template", "projects"."mirror", "projects"."mirror_user_id", "projects"."shared_runners_enabled", "projects"."runners_token", "projects"."build_coverage_regex", "projects"."build_allow_git_fetch", "projects"."build_timeout", "projects"."mirror_trigger_builds", "projects"."public_builds", "projects"."pending_delete", "projects"."last_repository_check_failed", "projects"."last_repository_check_at", "projects"."only_allow_merge_if_pipeline_succeeds", "projects"."has_external_issue_tracker", "projects"."repository_storage", "projects"."request_access_enabled", "projects"."has_external_wiki", "projects"."repository_read_only", "projects"."lfs_enabled", "projects"."description_html", "projects"."only_allow_merge_if_all_discussions_are_resolved", "projects"."repository_size_limit", "projects"."service_desk_enabled", "projects"."printing_merge_request_link_enabled", "projects"."auto_cancel_pending_pipelines", "projects"."cached_markdown_version", "projects"."last_repository_updated_at", "projects"."ci_config_path", "projects"."disable_overriding_approvers_per_merge_request", "projects"."delete_error", "projects"."storage_version", "projects"."resolve_outdated_diff_discussions", "projects"."remote_mirror_available_overridden", "projects"."only_mirror_protected_branches", "projects"."pull_mirror_available_overridden", "projects"."jobs_cache_index", "projects"."external_authorization_classification_label", "projects"."mirror_overwrites_diverged_branches", "projects"."external_webhook_token", "projects"."pages_https_only", "projects"."packages_enabled", "projects"."merge_requests_author_approval", "projects"."pool_repository_id", "projects"."runners_token_encrypted", "projects"."bfg_object_map", "projects"."detected_repository_languages", "projects"."merge_requests_disable_committers_approval", "projects"."require_password_to_approve", "projects"."emails_disabled", "projects"."max_pages_size", "projects"."max_artifacts_size", "projects"."remove_source_branch_after_merge", "projects"."marked_for_deletion_at", "projects"."marked_for_deletion_by_user_id", "projects"."suggestion_commit_message", "projects"."autoclose_referenced_issues", "projects"."project_namespace_id", "projects"."hidden" FROM "projects" WHERE "projects"."namespace_id" = 11150859
D, [2022-03-31T11:20:32.589876 #3413723] DEBUG -- : ChatTeam Load (0.9ms) /*application:console,db_config_name:main*/ SELECT "chat_teams".* FROM "chat_teams" WHERE "chat_teams"."namespace_id" = 11150859 LIMIT 1
D, [2022-03-31T11:20:32.617668 #3413723] DEBUG -- : Namespaces::UserNamespace Destroy (26.5ms) /*application:console,db_config_name:main*/ DELETE FROM "namespaces" WHERE "namespaces"."id" = 11150859
D, [2022-03-31T11:20:32.619983 #3413723] DEBUG -- : Key Load (0.9ms) /*application:console,db_config_name:main*/ SELECT "keys".* FROM "keys" WHERE "keys"."user_id" = 8306233 AND ("keys"."type" IN ('LDAPKey', 'Key') OR "keys"."type" IS NULL)
D, [2022-03-31T11:20:32.622558 #3413723] DEBUG -- : DeployKey Update All (0.8ms) /*application:console,db_config_name:main*/ UPDATE "keys" SET "user_id" = NULL WHERE "keys"."type" = 'DeployKey' AND "keys"."user_id" = 8306233
D, [2022-03-31T11:20:32.624591 #3413723] DEBUG -- : PersonalAccessToken Load (0.8ms) /*application:console,db_config_name:main*/ SELECT "personal_access_tokens".* FROM "personal_access_tokens" WHERE "personal_access_tokens"."user_id" = 8306233
D, [2022-03-31T11:20:32.626361 #3413723] DEBUG -- : Identity Load (0.7ms) /*application:console,db_config_name:main*/ SELECT "identities".* FROM "identities" WHERE "identities"."user_id" = 8306233
D, [2022-03-31T11:20:32.628701 #3413723] DEBUG -- : U2fRegistration Load (1.4ms) /*application:console,db_config_name:main*/ SELECT "u2f_registrations".* FROM "u2f_registrations" WHERE "u2f_registrations"."user_id" = 8306233
D, [2022-03-31T11:20:32.630875 #3413723] DEBUG -- : ChatName Load (1.2ms) /*application:console,db_config_name:main*/ SELECT "chat_names".* FROM "chat_names" WHERE "chat_names"."user_id" = 8306233
D, [2022-03-31T11:20:32.632549 #3413723] DEBUG -- : UsersStarProject Load (0.8ms) /*application:console,db_config_name:main*/ SELECT "users_star_projects".* FROM "users_star_projects" WHERE "users_star_projects"."user_id" = 8306233
D, [2022-03-31T11:20:32.634582 #3413723] DEBUG -- : ProjectAuthorization Destroy (0.7ms) /*application:console,db_config_name:main*/ DELETE FROM "project_authorizations" WHERE "project_authorizations"."user_id" = 8306233
D, [2022-03-31T11:20:32.636147 #3413723] DEBUG -- : Snippet Load (0.8ms) /*application:console,db_config_name:main*/ SELECT "snippets".* FROM "snippets" WHERE "snippets"."author_id" = 8306233
D, [2022-03-31T11:20:32.637813 #3413723] DEBUG -- : Note Load (0.7ms) /*application:console,db_config_name:main*/ SELECT "notes".* FROM "notes" WHERE "notes"."author_id" = 8306233
D, [2022-03-31T11:20:32.639729 #3413723] DEBUG -- : Issue Load (1.0ms) /*application:console,db_config_name:main*/ SELECT "issues".* FROM "issues" WHERE "issues"."author_id" = 8306233
D, [2022-03-31T11:20:32.643205 #3413723] DEBUG -- : MergeRequest Load (2.5ms) /*application:console,db_config_name:main*/ SELECT "merge_requests".* FROM "merge_requests" WHERE "merge_requests"."author_id" = 8306233
D, [2022-03-31T11:20:33.591912 #3413723] DEBUG -- : Event Destroy (947.0ms) /*application:console,db_config_name:main*/ DELETE FROM "events" WHERE "events"."author_id" = 8306233
D, [2022-03-31T11:20:33.596935 #3413723] DEBUG -- : Release Update All (3.4ms) /*application:console,db_config_name:main*/ UPDATE "releases" SET "author_id" = NULL WHERE "releases"."author_id" = 8306233
D, [2022-03-31T11:20:33.652076 #3413723] DEBUG -- : Subscription Load (53.9ms) /*application:console,db_config_name:main*/ SELECT "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."user_id" = 8306233
D, [2022-03-31T11:20:33.654370 #3413723] DEBUG -- : Doorkeeper::Application Load (0.9ms) /*application:console,db_config_name:main*/ SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."owner_id" = 8306233 AND "oauth_applications"."owner_type" = 'User'
D, [2022-03-31T11:20:33.657521 #3413723] DEBUG -- : AbuseReport Load (1.8ms) /*application:console,db_config_name:main*/ SELECT "abuse_reports".* FROM "abuse_reports" WHERE "abuse_reports"."user_id" = 8306233 LIMIT 1
D, [2022-03-31T11:20:33.659208 #3413723] DEBUG -- : AbuseReport Load (0.8ms) /*application:console,db_config_name:main*/ SELECT "abuse_reports".* FROM "abuse_reports" WHERE "abuse_reports"."reporter_id" = 8306233
D, [2022-03-31T11:20:33.661425 #3413723] DEBUG -- : SpamLog Load (1.4ms) /*application:console,db_config_name:main*/ SELECT "spam_logs".* FROM "spam_logs" WHERE "spam_logs"."user_id" = 8306233
D, [2022-03-31T11:20:33.663107 #3413723] DEBUG -- : AwardEmoji Load (0.7ms) /*application:console,db_config_name:main*/ SELECT "award_emoji".* FROM "award_emoji" WHERE "award_emoji"."user_id" = 8306233
D, [2022-03-31T11:20:33.665098 #3413723] DEBUG -- : PathLock Load (0.9ms) /*application:console,db_config_name:main*/ SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."user_id" = 8306233
D, [2022-03-31T11:20:33.666617 #3413723] DEBUG -- : Approval Load (0.6ms) /*application:console,db_config_name:main*/ SELECT "approvals".* FROM "approvals" WHERE "approvals"."user_id" = 8306233
D, [2022-03-31T11:20:33.668097 #3413723] DEBUG -- : Approver Load (0.7ms) /*application:console,db_config_name:main*/ SELECT "approvers".* FROM "approvers" WHERE "approvers"."user_id" = 8306233
D, [2022-03-31T11:20:33.669504 #3413723] DEBUG -- : ProtectedBranch::MergeAccessLevel Load (0.6ms) /*application:console,db_config_name:main*/ SELECT "protected_branch_merge_access_levels".* FROM "protected_branch_merge_access_levels" WHERE "protected_branch_merge_access_levels"."user_id" = 8306233
D, [2022-03-31T11:20:33.670883 #3413723] DEBUG -- : ProtectedBranch::PushAccessLevel Load (0.6ms) /*application:console,db_config_name:main*/ SELECT "protected_branch_push_access_levels".* FROM "protected_branch_push_access_levels" WHERE "protected_branch_push_access_levels"."user_id" = 8306233
D, [2022-03-31T11:20:33.672320 #3413723] DEBUG -- : ProtectedBranch::UnprotectAccessLevel Load (0.7ms) /*application:console,db_config_name:main*/ SELECT "protected_branch_unprotect_access_levels".* FROM "protected_branch_unprotect_access_levels" WHERE "protected_branch_unprotect_access_levels"."user_id" = 8306233
D, [2022-03-31T11:20:33.961500 #3413723] DEBUG -- : User Destroy (288.4ms) /*application:console,db_config_name:main*/ DELETE FROM "users" WHERE "users"."id" = 8306233
D, [2022-03-31T11:20:33.963366 #3413723] DEBUG -- : TRANSACTION (1.1ms) /*application:console,db_config_name:main*/ ROLLBACK
Traceback (most recent call last):
16: from (irb):27
15: from (irb):28:in `rescue in irb_binding'
14: from ee/app/services/ee/users/destroy_service.rb:10:in `execute'
13: from app/services/users/destroy_service.rb:68:in `execute'
12: from lib/gitlab/database/load_balancing/connection_proxy.rb:70:in `transaction'
11: from lib/gitlab/database/load_balancing/connection_proxy.rb:118:in `write_using_load_balancer'
10: from lib/gitlab/database/load_balancing/load_balancer.rb:110:in `read_write'
9: from lib/gitlab/database/load_balancing/load_balancer.rb:179:in `retry_with_backoff'
8: from lib/gitlab/database/load_balancing/load_balancer.rb:112:in `block in read_write'
7: from lib/gitlab/database/load_balancing/connection_proxy.rb:119:in `block in write_using_load_balancer'
6: from lib/gitlab/database/load_balancing/connection_proxy.rb:60:in `block (2 levels) in <class:ConnectionProxy>'
5: from lib/gitlab/database/load_balancing/connection_proxy.rb:118:in `write_using_load_balancer'
4: from lib/gitlab/database/load_balancing/load_balancer.rb:110:in `read_write'
3: from lib/gitlab/database/load_balancing/load_balancer.rb:179:in `retry_with_backoff'
2: from lib/gitlab/database/load_balancing/load_balancer.rb:112:in `block in read_write'
1: from lib/gitlab/database/load_balancing/connection_proxy.rb:119:in `block in write_using_load_balancer'
ActiveRecord::NotNullViolation (PG::NotNullViolation: ERROR: null value in column "author_id" violates not-null constraint)
DETAIL: Failing row contains (15565320, null, null, 28629009, null, null, null, null, null, null, 2021-08-11 16:30:07.844913+00, 2022-02-28 13:52:43.842638+00, null, null, 1, 7, 2, f, f, Secret Scanner: Possible Password Finding (Text: Password) v1.0...., Secret Scanner: Possible Password Finding (Text: Password) v1.0...., null, , 4, 1900549, null, null, null, null, null, null, f, t, 2021-08-11 16:30:07.839446+00).
CONTEXT: SQL statement "UPDATE ONLY "public"."vulnerabilities" SET "author_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "author_id""
As from our intial investigation it looks like it is failing on updating Table "public.vulnerabilities"
tagging relevant team members.
cc// @matt_wilson @thiagocsf
Implementation plan
- Adjust
app/services/users/migrate_to_ghost_user_service.rb
to migrateVulnerabilities
toUser.ghost
- Adjust
app/services/users/migrate_to_ghost_user_service.rb
to migrateVulnerabilities::ExternalIssueLinks
toUser.ghost
Edited by Michał Zając