Destroying a project can fail if there are a large number of MR's
Summary
A project with around 5000 MR's failed to get removed from the UI.
Steps to reproduce
- Create a project with > 5000+ MR's
- Run
ProjectDestroyWorker.new.perform(<project_id>, <authorised_user_id>)
What is the current bug behavior?
The worker failed to complete with the following error:
[ gprd ] production> p.delete_error
=> "PG::QueryCanceled: ERROR: canceling statement due to statement timeout\nCONTEXT: SQL statement \"DELETE FROM ONLY \"public\".\"merge_request_diff_commits\" WHERE $1 OPERATOR(pg_catalog.=) \"merge_request_diff_id\"\"\n"
What is the expected correct behavior?
ProjectDestroyWorker
should successfully remove a project with these many MR's
Output of checks
[ gprd ] production> p.merge_requests.count
D, [2021-06-11T08:36:31.316039 #5504] DEBUG -- : (14.3ms) /*application:console*/ SELECT COUNT(*) FROM "merge_requests" WHERE "merge_requests"."target_project_id" = 25216063
=> 4098
This bug happens on GitLab.com
Possible fixes
Something similar to this: #207222 (closed)
links
https://gitlab.com/gitlab-com/support/internal-requests/-/issues/7146
Please note this also happens when the project has a large number of pipelines to delete.
Edited by Arihant