Project import data inserts are racy
The following discussion from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2551 should be addressed:
-
@nick.thomas started a discussion: (+2 comments) There's a race condition here.
Start with a brand-new project and type
ssh://example.com
really fast.Multiple
PUT
s happen. This exposes a bug in the backend where multipleProjectImportData
records end up being created, each with their own SSH key. This causes us to switch randomly between keys as there's no ordering applied.I'll apply a fix to the backend, but we need to do away with the race here too (otherwise you'll start getting error responses).
We need to prevent any more PUTs from being run or queued while the first one is in progress.
The basic issue is that we don't have a unique index on project_import_data.project_id
We also don't have a NOT NULL
requirement.
Both of these things should be fixed, but I'm of the opinion they can go in separately to https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2551