Follow-up from "Sync organization_id to CI mirror tables"
The following discussions from !254205 (merged) should be addressed:
-
@bmarjanovic started a discussion: (+1 comment)
<
🤖 >issue (non-blocking): This callback won't fire on the main production path that changes
organization_id.Organizations::Transfer::GroupsService#transfer_namespaces_and_projects(app/services/organizations/transfer/groups_service.rb) andOrganizations::Transfer::TopLevelGroupService(app/services/organizations/transfer/top_level_group_service.rb) both changeorganization_idviaupdate_all, which bypasses ActiveRecord callbacks. So thisafter_updateonNamespace, and the equivalentafter_saveonProject, never run during an organization transfer.The new triggers still insert rows into
namespaces_sync_eventsandprojects_sync_events, butNamespaces::ProcessSyncEventsWorkerandProjects::ProcessSyncEventsWorkeraren't cron-scheduled. OnlyCi::Catalog::Resources::ProcessSyncEventsWorkeris inconfig/schedule.yml. These two only run when a model callback enqueues them, or whenCi::ProcessSyncEventsServicere-enqueues after finding leftover events. So after a transfer,ci_namespace_mirrorsandci_project_mirrorscan keep the staleorganization_iduntil some unrelated namespace or project save happens to trigger a worker. Usually seconds on GitLab.com, but potentially indefinite on a quiet self-managed instance.Since !254210 plans to rely on
organization_idon the mirror tables for CI database data isolation, this needs to be fixed before that lands, either here or as a follow-up MR in this series.GroupsServicealready has the pattern to reuse: it enqueuesCi::Runners::TransferOrganizationWorkerand other workers insideActiveRecord.after_all_transactions_commit do ... end, with a comment explaining thatgroupnever joins the transaction because all writes go throughupdate_all.ActiveRecord.after_all_transactions_commit do Namespaces::SyncEvent.enqueue_worker Projects::SyncEvent.enqueue_worker end</
🤖 > -
@bmarjanovic started a discussion:
<
🤖 >nitpick (non-blocking):
doc/development/database/ci_mirrored_tables.md(around lines 64-67) still says replication is restricted to a few attributes,traversal_idsfromNamespace, and onlynamespace_idfromProject. After this MR,organization_idis also replicated from bothNamespaceandProject, so that paragraph is out of date.Suggest a one-line update to mention
organization_id, either here or in a follow-up.</
🤖 >