Commit e8704cbe authored by Adam Hegyi's avatar Adam Hegyi

Merge branch 'if-330967-fix_root_traversal_ids_backfill' into 'master'

Fix query timeouts in BackfillNamespaceTraversalIdsRoots

See merge request gitlab-org/gitlab!61781
parents 63a906eb 2d059781
......@@ -22,7 +22,16 @@ module Gitlab
.where("traversal_ids = '{}'")
ranged_query.each_batch(of: sub_batch_size) do |sub_batch|
sub_batch.update_all('traversal_ids = ARRAY[id]')
first, last = sub_batch.pluck(Arel.sql('min(id), max(id)')).first
# The query need to be reconstructed because .each_batch modifies the default scope
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/330510
Namespace.unscoped
.base_query
.where(id: first..last)
.where("traversal_ids = '{}'")
.update_all('traversal_ids = ARRAY[id]')
sleep PAUSE_SECONDS
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment