Commit 8f649056 authored by Etienne Baqué's avatar Etienne Baqué

Merge branch 'eb-remove-efficient-counter-attribute-ff' into 'master'

Remove efficient_counter_attribute flag

See merge request gitlab-org/gitlab!68056
parents a7a4b853 9118e2bc
...@@ -128,8 +128,7 @@ module CounterAttribute ...@@ -128,8 +128,7 @@ module CounterAttribute
end end
def counter_attribute_enabled?(attribute) def counter_attribute_enabled?(attribute)
Feature.enabled?(:efficient_counter_attribute, project) && self.class.counter_attributes.include?(attribute)
self.class.counter_attributes.include?(attribute)
end end
private private
......
---
name: efficient_counter_attribute
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/35878
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/238535
milestone: '13.3'
type: development
group: group::pipeline execution
default_enabled: false
...@@ -401,12 +401,6 @@ RSpec.describe ProjectStatistics do ...@@ -401,12 +401,6 @@ RSpec.describe ProjectStatistics do
let(:stat) { :build_artifacts_size } let(:stat) { :build_artifacts_size }
it_behaves_like 'a statistic that increases storage_size asynchronously' it_behaves_like 'a statistic that increases storage_size asynchronously'
it_behaves_like 'a statistic that increases storage_size' do
before do
stub_feature_flags(efficient_counter_attribute: false)
end
end
end end
context 'when adjusting :pipeline_artifacts_size' do context 'when adjusting :pipeline_artifacts_size' do
......
...@@ -62,26 +62,6 @@ RSpec.shared_examples_for CounterAttribute do |counter_attributes| ...@@ -62,26 +62,6 @@ RSpec.shared_examples_for CounterAttribute do |counter_attributes|
.to raise_error(ActiveModel::MissingAttributeError) .to raise_error(ActiveModel::MissingAttributeError)
end end
end end
context 'when feature flag is disabled' do
before do
stub_feature_flags(efficient_counter_attribute: false)
end
it 'delegates to ActiveRecord update!' do
expect { subject }
.to change { model.reset.read_attribute(attribute) }.by(increment)
end
it 'does not increment the counter in Redis' do
subject
Gitlab::Redis::SharedState.with do |redis|
counter = redis.get(model.counter_key(attribute))
expect(counter).to be_nil
end
end
end
end end
end end
end end
......
...@@ -22,116 +22,6 @@ RSpec.shared_examples 'UpdateProjectStatistics' do |with_counter_attribute| ...@@ -22,116 +22,6 @@ RSpec.shared_examples 'UpdateProjectStatistics' do |with_counter_attribute|
it { is_expected.to be_new_record } it { is_expected.to be_new_record }
context 'when feature flag efficient_counter_attribute is disabled' do
before do
stub_feature_flags(efficient_counter_attribute: false)
end
context 'when creating' do
it 'updates the project statistics' do
delta0 = reload_stat
subject.save!
delta1 = reload_stat
expect(delta1).to eq(delta0 + read_attribute)
expect(delta1).to be > delta0
end
it 'schedules a namespace statistics worker' do
expect(Namespaces::ScheduleAggregationWorker)
.to receive(:perform_async).once
subject.save!
end
end
context 'when updating' do
let(:delta) { 42 }
before do
subject.save!
end
it 'updates project statistics' do
expect(ProjectStatistics)
.to receive(:increment_statistic)
.and_call_original
subject.write_attribute(statistic_attribute, read_attribute + delta)
expect { subject.save! }
.to change { reload_stat }
.by(delta)
end
it 'schedules a namespace statistics worker' do
expect(Namespaces::ScheduleAggregationWorker)
.to receive(:perform_async).once
subject.write_attribute(statistic_attribute, read_attribute + delta)
subject.save!
end
it 'avoids N + 1 queries' do
subject.write_attribute(statistic_attribute, read_attribute + delta)
control_count = ActiveRecord::QueryRecorder.new do
subject.save!
end
subject.write_attribute(statistic_attribute, read_attribute + delta)
expect do
subject.save!
end.not_to exceed_query_limit(control_count)
end
end
context 'when destroying' do
before do
subject.save!
end
it 'updates the project statistics' do
delta0 = reload_stat
subject.destroy!
delta1 = reload_stat
expect(delta1).to eq(delta0 - read_attribute)
expect(delta1).to be < delta0
end
it 'schedules a namespace statistics worker' do
expect(Namespaces::ScheduleAggregationWorker)
.to receive(:perform_async).once
subject.destroy!
end
context 'when it is destroyed from the project level' do
it 'does not update the project statistics' do
expect(ProjectStatistics)
.not_to receive(:increment_statistic)
project.update!(pending_delete: true)
project.destroy!
end
it 'does not schedule a namespace statistics worker' do
expect(Namespaces::ScheduleAggregationWorker)
.not_to receive(:perform_async)
project.update!(pending_delete: true)
project.destroy!
end
end
end
end
def expect_flush_counter_increments_worker_performed def expect_flush_counter_increments_worker_performed
expect(FlushCounterIncrementsWorker) expect(FlushCounterIncrementsWorker)
.to receive(:perform_in) .to receive(:perform_in)
......
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