ci_namespace_mirrors and ci_project_mirrors consistency check

From: https://gitlab.com/gitlab-org/gitlab/-/issues/346786#note_821348824

So far we validated this manually that this is coherent. I wonder if we can somehow have a semi-automatic/or-automatic way to do this validation to ensure the consistency between data. Some ideas:

  • Run the above queries as part of rake task, but taking into account the decomposed database
  • Run the above queries by cron, by doing a sampling/randomisation of a small subset of the ci_namespace_mirrors and by statistical significance over longer period we effectively check each record

I think the most important is comparing the coherence between traversal_ids, less relevent if we have extra records present in ci_namespace_mirrors vs namespaces. This responsibility of validating deletion behavior is more related to loose foreign key implementation.

Likely we should document approaches and proposals as part of a follow-up.