Implement Namespaces::StatePropagationIterator subclass
Summary
Create a subclass of Gitlab::Database::NamespaceEachBatch that adds state-aware filtering to the tree iterator's DFS traversal, enabling propagation boundary enforcement.
Tasks
- Create
app/models/namespaces/state_propagation_iterator.rbsubclassingGitlab::Database::NamespaceEachBatch - Accept a
state_filterparameter (array of overwritable state values) - Override
walk_downto addAND state IN (overwritable_states)to the LATERAL subquery that finds the first child - Override
next_elementsto add the same state filter to the LATERAL subquery that finds the next sibling - Ensure the DFS skips namespaces with states not in the filter, pruning their entire subtrees
- Verify the iterator still works correctly with cursor-based batching and the
of:batch size parameter
References
Edited by 🤖 GitLab Bot 🤖