Commit 15089f98 authored by Andreas Brandl's avatar Andreas Brandl

Reset memoized bloat estimation upon #reset

parent dfe060f0
...@@ -38,7 +38,10 @@ module Gitlab ...@@ -38,7 +38,10 @@ module Gitlab
where('NOT EXISTS (?)', recent_actions) where('NOT EXISTS (?)', recent_actions)
end end
alias_method :reset, :reload def reset
reload # rubocop:disable Cop/ActiveRecordAssociationReload
clear_memoization(:bloat_size)
end
def bloat_size def bloat_size
strong_memoize(:bloat_size) { bloat_estimate&.bloat_size || 0 } strong_memoize(:bloat_size) { bloat_estimate&.bloat_size || 0 }
......
...@@ -107,6 +107,24 @@ RSpec.describe Gitlab::Database::PostgresIndex do ...@@ -107,6 +107,24 @@ RSpec.describe Gitlab::Database::PostgresIndex do
end end
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 describe '#unique?' do
it 'returns true for a unique index' do it 'returns true for a unique index' do
expect(find('public.bar_key')).to be_unique 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