Use batched pre-drain in Groups::DestroyService
Summary
Apply the same batched pre-drain pattern to group destruction. Delete direct group children in committed batches before calling group.destroy!.
Context
Groups are simpler than projects. Most heavy data lives under projects, which are destroyed first. But direct group children (group_members, labels, milestones, boards, epics, namespace_settings) can still cause long transactions for large groups.
Requirements
- Pre-drain before destroy. Call
BatchedPreDrainfor the group's directCASCADEFK children before callinggroup.destroy!. - Register hooks for group children with side effects (e.g. avatar uploads).
- Re-enqueue on budget exhaustion. If the pre-drain returns
:over_budget, re-enqueue the worker. The group stays marked for deletion. The next run continues. - Destroy the group. Once the pre-drain finishes, call
group.destroy!with minimal remaining cascade. - Preserve existing ordering. The pre-drain must run after child projects are destroyed, matching the current destroy flow.
Specs
- Pre-drain runs before
destroy! - Worker re-enqueues on
:over_budget - Re-runs after partial drain are idempotent
- Correct ordering relative to child project destruction
Dependencies
Depends on the generic batched pre-drain helper (#619116).
References
- Parent epic: gitlab-org#23353
- Design document MR: gitlab-com/content-sites/handbook!20016
Edited by 🤖 GitLab Bot 🤖