Mutator RPCs insert state in Praefect for non-existing repos
As discussed in gitlab#9803 (comment 422414267) - Praefect runs IncrementGeneration on all mutator RPCs, which inserts the repo state in the Praefect DB if it doesn't exist (or updates it if exists).
The problem is it also does it if it doesn't physically exist, so you end up with a repo on that storage in the DB, then any further attempts to create the repo will fail with a duplicate index error (because it already exists in the DB):
pq: duplicate key value violates unique constraint \"storage_repositories_pkey\"
This can cause problems if there is no repository.exists check before, or because of a Rails bug (like, for example happened in Geo secondaries in gitlab#9803 (comment 422414267))
Maybe we should have a check when inserting state for a non-existing repository, otherwise further attempts to create/rename this repository would fail because of the unique constraint above.
/cc @samihiltunen