Currently our repository removal process can be broken into two steps:
1.Remove the repository and the references of the repo from the config descriptor
2.Remove all the related entries from the database for the corresponding repo
This process is sometimes problematic. Occasionally, customers will attempt to delete a repo and the deletion will error out, leaving the repo references in the database (as if it wasn't removed), but the repo will not show in the repositories list (or on the config descriptor) since step #1 did actually complete.
The problem with this is that it is step #2 that is most prone to errors (i.e database errors, lock problems etc), and the one that usually fails.
Due to that, when a error occurs during the deletion, the server will be left in an inconsistent state with repos that will never be cleaned. The only way to complete the removal process is to remove the entries from the database directly.
If the step order was different, than the user could re-attempt to delete the repo following an error.