Automatically delete orphaned upload records
Depends on https://gitlab.com/gitlab-org/gitlab-ee/issues/7184.
In rare cases it is possible for Upload records to be orphaned, even though the Upload class validates for the presence of model
. We would have added a DB constraint, but we can't because the association is polymorphic.
So, on DB writeable GitLab instances (i.e. not on Geo secondary nodes), in the upload verification service, we should destroy the Upload if its model does not exist.
Acceptance criteria:
- Set up GitLab Geo
- Add a project, add an issue, add an upload in it
- Manually delete the project record on the primary e.g.
Project.last.delete
- Wait for upload verification
- The upload record and file should disappear from the primary
- The upload record should disappear from the secondary by DB replication
- Wait for UploadDeletedEvent to be processed
- The upload file should disappear from the secondary