Ensure Sec DB remains in sync with CI mirror tables
Problem to solve
Once we have support for a dedicated sec DB we need to ensure we have some level of continuity with our core application tables. With the decomposition of the CI DB the mirror tables async approach was adopted. We should ensure we maintain similar mirroring within the Sec DB.
Proposal
Mirror projects and namespaces table to sec_project_mirrors and sec_namespace_mirrors.
Mirrors for sec are similar to the mirrors for ci,
and they're synchronized the same way using consistency check workers and loose foreign keys.
#466288 (comment 2279233198)
sec_project_mirrors and sec_namespace_mirrors
are similar to ci_project_mirrors and ci_namespaces_mirrors,
except for the mirroring of additional columns. #466288 (comment 2279233198)
projects.archivedprojects.delete_pendingnamespaces.traversal_ids
sec_*_mirrors tables belong to the gitlab_sec schema
the same way ci_*_mirrors table belong to the gitlab_ci schema.
Mirrored data isn't shared b/w ci and sec.
This is optimized for simplicy:
we have a single codepath which matches the requirements of gitlab.com.
#466288 (comment 2280756035)
Implementation plan
See #466288 (comment 2280807389)
-
Establish whether the mirrors are shared b/w ciandsec. No, see #466288 (comment 2280756035). -
Create tables and models similar to Ci::ProjectMirrorandCi::NamespaceMirror. Addhas_onerelations to the source tables. -
Declare loose foreign keys b/w these mirrors and their source tables. -
Update Namespaces::ProcessSyncEventsWorkerandProjects::ProcessSyncEventsWorkerto sync the new mirrors when projects and namespaces are added or updated. #466288 (comment 2284979850)
Then, when the sync workers are in place,
-
Backfill the mirrors using batched background migrations similar to BackfillCiNamespaceMirrorsandBackfillCiProjectMirrors#466288 (comment 2282357594)
Then, when mirrors have been backfilled,
-
Port/duplicate Database::CiProjectMirrorsConsistencyCheckWorkerandDatabase::CiNamespaceMirrorsConsistencyCheckWorkerto check and fix the new mirrors. -
Use the mirror to decompose an existing feature which causes a cross-database join involving projectsand/ornamespace. Example: Resolve cross-join in ProjectsGrades.grades_for... (#503387 - closed) (for groups)
See Decomposition: Make Ops features compatible wit... (&6379 - closed)