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
09cdfb16
Commit
09cdfb16
authored
Jun 24, 2021
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup unneeded code
parent
37ddbe2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
32 deletions
+1
-32
lib/gitlab/database/reindexing/reindex_concurrently.rb
lib/gitlab/database/reindexing/reindex_concurrently.rb
+0
-3
spec/lib/gitlab/database/reindexing/reindex_concurrently_spec.rb
...b/gitlab/database/reindexing/reindex_concurrently_spec.rb
+1
-29
No files found.
lib/gitlab/database/reindexing/reindex_concurrently.rb
View file @
09cdfb16
...
...
@@ -5,8 +5,6 @@ module Gitlab
module
Reindexing
# This is a >= PG12 reindexing strategy based on `REINDEX CONCURRENTLY`
class
ReindexConcurrently
include
Gitlab
::
Utils
::
StrongMemoize
ReindexError
=
Class
.
new
(
StandardError
)
TEMPORARY_INDEX_PATTERN
=
'\_ccnew[0-9]*'
...
...
@@ -45,7 +43,6 @@ module Gitlab
execute
(
"REINDEX INDEX CONCURRENTLY
#{
quote_table_name
(
index
.
schema
)
}
.
#{
quote_table_name
(
index
.
name
)
}
"
)
end
end
ensure
cleanup_dangling_indexes
end
...
...
spec/lib/gitlab/database/reindexing/reindex_concurrently_spec.rb
View file @
09cdfb16
...
...
@@ -70,7 +70,7 @@ RSpec.describe Gitlab::Database::Reindexing::ReindexConcurrently, '#perform' do
subject
end
context
'with dangling indexes
matching TEMPORARY_INDEX_PATTERN, i.e. /some\_index\_ccnew(\d)*/'
do
context
'with dangling indexes matching TEMPORARY_INDEX_PATTERN, i.e. /some\_index\_ccnew(\d)*/'
do
before
do
# dangling indexes
connection
.
execute
(
"CREATE INDEX
#{
index_name
}
_ccnew ON
#{
table_name
}
(
#{
column_name
}
)"
)
...
...
@@ -109,32 +109,4 @@ RSpec.describe Gitlab::Database::Reindexing::ReindexConcurrently, '#perform' do
end
end
end
def
expect_index_rename
(
from
,
to
)
expect
(
connection
).
to
receive
(
:execute
).
with
(
<<~
SQL
).
ordered
ALTER INDEX "public"."
#{
from
}
"
RENAME TO "
#{
to
}
"
SQL
end
def
expect_index_drop
(
drop_index
)
expect_next_instance_of
(
::
Gitlab
::
Database
::
WithLockRetries
)
do
|
instance
|
expect
(
instance
).
to
receive
(
:run
).
with
(
raise_on_exhaustion:
false
).
and_yield
end
expect_to_execute_concurrently_in_order
(
drop_index
)
end
def
find_index_create_statement
ActiveRecord
::
Base
.
connection
.
select_value
(
<<~
SQL
)
SELECT indexdef
FROM pg_indexes
WHERE schemaname = 'public'
AND indexname =
#{
ActiveRecord
::
Base
.
connection
.
quote
(
index
.
name
)
}
SQL
end
def
check_index_exists
expect
(
find_index_create_statement
).
to
eq
(
original_index
)
end
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