Skip to content

Remove DeleteOrphanedGroups as it depends on application code

Problem

The DeleteOrphanedGroups batched background migration (BBM) spec is failing in https://gitlab.com/gitlab-org/gitlab/-/jobs/11439235448 because it depends on application code.

Specifically, the spec at ./spec/lib/gitlab/background_migration/delete_orphaned_groups_spec.rb:59 fails due to the state_metadata JSON schema validation in the Namespace model introduced in !198956 (merged). This validation doesn't work with the BBM because:

  1. BBM specs run on the schema version that finalized the migration
  2. Database changes are rolled back to that version, but application code changes (like validations) are not
  3. This violates the BBM isolation principle - BBMs should not depend on application code

Background

The DeleteOrphanedGroups BBM was already finalized in GitLab 18.0 by the migration db/post_migrate/20250506055121_finalize_delete_orphaned_groups.rb.

Proposal

Remove the DeleteOrphanedGroups BBM and its associated spec entirely, since:

  • The migration has been finalized since 18.0
  • It depends on application code, which is an anti-pattern
  • Keeping it creates maintenance burden and test failures

Related

Edited by 🤖 GitLab Bot 🤖