Commit 85cc12e7 authored by Andreas Brandl's avatar Andreas Brandl

Remove upper index size limit for reindexing

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/345134
parent 9659e770
...@@ -9,8 +9,8 @@ module Gitlab ...@@ -9,8 +9,8 @@ module Gitlab
# Only reindex indexes with a relative bloat level (bloat estimate / size) higher than this # Only reindex indexes with a relative bloat level (bloat estimate / size) higher than this
MINIMUM_RELATIVE_BLOAT = 0.2 MINIMUM_RELATIVE_BLOAT = 0.2
# Only consider indexes with a total ondisk size in this range (before reindexing) # Only consider indexes beyond this size (before reindexing)
INDEX_SIZE_RANGE = (1.gigabyte..100.gigabyte).freeze INDEX_SIZE_MINIMUM = 1.gigabyte
delegate :each, to: :indexes delegate :each, to: :indexes
...@@ -32,7 +32,7 @@ module Gitlab ...@@ -32,7 +32,7 @@ module Gitlab
@indexes ||= candidates @indexes ||= candidates
.not_recently_reindexed .not_recently_reindexed
.where(ondisk_size_bytes: INDEX_SIZE_RANGE) .where('ondisk_size_bytes >= ?', INDEX_SIZE_MINIMUM)
.sort_by(&:relative_bloat_level) # forced N+1 .sort_by(&:relative_bloat_level) # forced N+1
.reverse .reverse
.select { |candidate| candidate.relative_bloat_level >= MINIMUM_RELATIVE_BLOAT } .select { |candidate| candidate.relative_bloat_level >= MINIMUM_RELATIVE_BLOAT }
......
...@@ -46,14 +46,14 @@ RSpec.describe Gitlab::Database::Reindexing::IndexSelection do ...@@ -46,14 +46,14 @@ RSpec.describe Gitlab::Database::Reindexing::IndexSelection do
expect(subject).not_to include(excluded.index) expect(subject).not_to include(excluded.index)
end end
it 'excludes indexes larger than 100 GB ondisk size' do it 'includes indexes larger than 100 GB ondisk size' do
excluded = create( included = create(
:postgres_index_bloat_estimate, :postgres_index_bloat_estimate,
index: create(:postgres_index, ondisk_size_bytes: 101.gigabytes), index: create(:postgres_index, ondisk_size_bytes: 101.gigabytes),
bloat_size_bytes: 25.gigabyte bloat_size_bytes: 25.gigabyte
) )
expect(subject).not_to include(excluded.index) expect(subject).to include(included.index)
end end
context 'with time frozen' do context 'with time frozen' do
......
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