Deletion of invalid repositories can deadlock
When the per-repository elector tries to delete invalid repositories, then it first deletes from storage_repositories
and then it deletes from repositories
. This order is different to all the other queries which first delete from repositories
and then from storage_repositories
. As a consequence, this can deadlock.