Commit 09cdfb16 authored by Andreas Brandl's avatar Andreas Brandl

Cleanup unneeded code

parent 37ddbe2f
......@@ -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
......
......@@ -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
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