Forked project deletion fails due to SQL timeout on source_project_id nil updation
Summary
#295201 (closed) fixed the problem of SQL timeout when setting source_project_id
to nil
for non-forked projects.
The issue was fixed by re-ordering the FK constraint for source_project_id
(ON DELETE SET NULL
) to be positioned after target_project_id
(ON DELETE CASCADE
). This will ensure the merge requests get deleted first and then trigger the updation of source_project_id
to nil
.
This however fixes the problem only for non-forked projects.
For a forked project, the MRs can have source_project_id
= forked project, and target_project_id
= parent fork project. When the forked project is deleted, such MRs are closed and their source_project_id
is set to nil
(via ON DELETE SET NULL
condition).
When forked projects have large number of merge requests, it can result in SQL timeout.
Steps to reproduce
- Create a fork from a project
- Create MRs sourced from the forked project, and targeted to the parent fork
- Try deleting the fork project
There is a possibility the project deletion fails due to time out.
What is the current bug behavior?
Currently, there is a possibility for deletion of forked projects to fail due to SQL time out on source_project_id
nil
updation.
What is the expected correct behavior?
Forked projects should delete seamlessly, without timing out during source_project_id
nil
updation.
Possible fixes
Once delayed deletion of projects is implemented, updating source_project_id
to nil
can be done asynchronously and in batches.