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
0d8d12ee
Commit
0d8d12ee
authored
Oct 01, 2020
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude lingering indexes from reindexing
parent
2ddfd434
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
2 deletions
+20
-2
lib/gitlab/database/reindexing.rb
lib/gitlab/database/reindexing.rb
+7
-0
lib/tasks/gitlab/db.rake
lib/tasks/gitlab/db.rake
+1
-1
spec/lib/gitlab/database/reindexing_spec.rb
spec/lib/gitlab/database/reindexing_spec.rb
+11
-0
spec/tasks/gitlab/db_rake_spec.rb
spec/tasks/gitlab/db_rake_spec.rb
+1
-1
No files found.
lib/gitlab/database/reindexing.rb
View file @
0d8d12ee
...
@@ -10,6 +10,13 @@ module Gitlab
...
@@ -10,6 +10,13 @@ module Gitlab
end
end
end
end
end
end
def
self
.
candidate_indexes
Gitlab
::
Database
::
PostgresIndex
.
regular
.
not_match
(
"^
#{
ConcurrentReindex
::
TEMPORARY_INDEX_PREFIX
}
"
)
.
not_match
(
"^
#{
ConcurrentReindex
::
REPLACED_INDEX_PREFIX
}
"
)
end
end
end
end
end
end
end
lib/tasks/gitlab/db.rake
View file @
0d8d12ee
...
@@ -177,7 +177,7 @@ namespace :gitlab do
...
@@ -177,7 +177,7 @@ namespace :gitlab do
indexes
=
if
args
[
:index_name
]
indexes
=
if
args
[
:index_name
]
Gitlab
::
Database
::
PostgresIndex
.
by_identifier
(
args
[
:index_name
])
Gitlab
::
Database
::
PostgresIndex
.
by_identifier
(
args
[
:index_name
])
else
else
Gitlab
::
Database
::
PostgresIndex
.
regular
.
random_few
(
2
)
Gitlab
::
Database
::
Reindexing
.
candidate_indexes
.
random_few
(
2
)
end
end
Gitlab
::
Database
::
Reindexing
.
perform
(
indexes
)
Gitlab
::
Database
::
Reindexing
.
perform
(
indexes
)
...
...
spec/lib/gitlab/database/reindexing_spec.rb
View file @
0d8d12ee
...
@@ -52,4 +52,15 @@ RSpec.describe Gitlab::Database::Reindexing do
...
@@ -52,4 +52,15 @@ RSpec.describe Gitlab::Database::Reindexing do
it_behaves_like
'reindexing'
it_behaves_like
'reindexing'
end
end
end
end
describe
'.candidate_indexes'
do
subject
{
described_class
.
candidate_indexes
}
it
'retrieves regular indexes that are no left-overs from previous runs'
do
result
=
double
expect
(
Gitlab
::
Database
::
PostgresIndex
).
to
receive_message_chain
(
'regular.not_match.not_match'
).
with
(
no_args
).
with
(
'^tmp_reindex_'
).
with
(
'^old_reindex_'
).
and_return
(
result
)
expect
(
subject
).
to
eq
(
result
)
end
end
end
end
spec/tasks/gitlab/db_rake_spec.rb
View file @
0d8d12ee
...
@@ -170,7 +170,7 @@ RSpec.describe 'gitlab:db namespace rake task' do
...
@@ -170,7 +170,7 @@ RSpec.describe 'gitlab:db namespace rake task' do
context
'when no index_name is given'
do
context
'when no index_name is given'
do
it
'rebuilds a random number of large indexes'
do
it
'rebuilds a random number of large indexes'
do
expect
(
Gitlab
::
Database
::
PostgresIndex
).
to
receive_message_chain
(
'regular
.random_few'
).
and_return
(
indexes
)
expect
(
Gitlab
::
Database
::
Reindexing
).
to
receive_message_chain
(
'candidate_indexes
.random_few'
).
and_return
(
indexes
)
expect
(
Gitlab
::
Database
::
Reindexing
).
to
receive
(
:perform
).
with
(
indexes
)
expect
(
Gitlab
::
Database
::
Reindexing
).
to
receive
(
:perform
).
with
(
indexes
)
run_rake_task
(
'gitlab:db:reindex'
)
run_rake_task
(
'gitlab:db:reindex'
)
...
...
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