Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2d059781
Commit
2d059781
authored
May 14, 2021
by
Imre Farkas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix query timeouts in BackfillNamespaceTraversalIdsRoots
Timeouts are due to the query plan using wrong index.
parent
6f8c1e3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
lib/gitlab/background_migration/backfill_namespace_traversal_ids_roots.rb
...round_migration/backfill_namespace_traversal_ids_roots.rb
+10
-1
No files found.
lib/gitlab/background_migration/backfill_namespace_traversal_ids_roots.rb
View file @
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment