datastore: Fix potential deadlock when deleting invalid repo storages
When modifying the repositories
and storage_repositories
tables,
then all functions first modify the repositories
table. The only
exception to this is DeleteInvalidRepositories()
, which first deletes
the record from the storage_repositories
table. This can thus lead to
a deadlock in case the query runs concurrently with any of the other
queries and touches the same rows.
Fix the deadlock by reversing the order.
Changelog: fixed
Closes #3910 (closed)