Commit 604fe9aa authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'ab/reindexing-reset-bloat-estimate' into 'master'

Reset memoized bloat estimation upon #reset

See merge request gitlab-org/gitlab!65833
parents 2e58f1ac 15089f98
......@@ -38,7 +38,10 @@ module Gitlab
where('NOT EXISTS (?)', recent_actions)
end
alias_method :reset, :reload
def reset
reload # rubocop:disable Cop/ActiveRecordAssociationReload
clear_memoization(:bloat_size)
end
def bloat_size
strong_memoize(:bloat_size) { bloat_estimate&.bloat_size || 0 }
......
......@@ -107,6 +107,24 @@ RSpec.describe Gitlab::Database::PostgresIndex do
end
end
describe '#reset' do
subject { index.reset }
let(:index) { described_class.by_identifier(identifier) }
it 'calls #reload' do
expect(index).to receive(:reload).once.and_call_original
subject
end
it 'resets the bloat estimation' do
expect(index).to receive(:clear_memoization).with(:bloat_size).and_call_original
subject
end
end
describe '#unique?' do
it 'returns true for a unique index' do
expect(find('public.bar_key')).to be_unique
......
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