Commit 45a05a8b authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 284ae7dd
...@@ -170,8 +170,8 @@ group :unicorn do ...@@ -170,8 +170,8 @@ group :unicorn do
end end
group :puma do group :puma do
gem 'puma', '~> 3.12', require: false gem 'puma', '~> 4.3.0', require: false
gem 'puma_worker_killer', require: false gem 'puma_worker_killer', '~> 0.1.1', require: false
gem 'rack-timeout', require: false gem 'rack-timeout', require: false
end end
......
...@@ -749,10 +749,11 @@ GEM ...@@ -749,10 +749,11 @@ GEM
pry-rails (0.3.6) pry-rails (0.3.6)
pry (>= 0.10.4) pry (>= 0.10.4)
public_suffix (3.1.1) public_suffix (3.1.1)
puma (3.12.0) puma (4.3.0)
puma_worker_killer (0.1.0) nio4r (~> 2.0)
puma_worker_killer (0.1.1)
get_process_mem (~> 0.2) get_process_mem (~> 0.2)
puma (>= 2.7, < 4) puma (>= 2.7, < 5)
pyu-ruby-sasl (0.0.3.3) pyu-ruby-sasl (0.0.3.3)
raabro (1.1.6) raabro (1.1.6)
rack (2.0.7) rack (2.0.7)
...@@ -1280,8 +1281,8 @@ DEPENDENCIES ...@@ -1280,8 +1281,8 @@ DEPENDENCIES
prometheus-client-mmap (~> 0.9.10) prometheus-client-mmap (~> 0.9.10)
pry-byebug (~> 3.5.1) pry-byebug (~> 3.5.1)
pry-rails (~> 0.3.4) pry-rails (~> 0.3.4)
puma (~> 3.12) puma (~> 4.3.0)
puma_worker_killer puma_worker_killer (~> 0.1.1)
rack (~> 2.0.7) rack (~> 2.0.7)
rack-attack (~> 6.2.0) rack-attack (~> 6.2.0)
rack-cors (~> 1.0.0) rack-cors (~> 1.0.0)
......
...@@ -49,8 +49,7 @@ module UpdateProjectStatistics ...@@ -49,8 +49,7 @@ module UpdateProjectStatistics
attr = self.class.statistic_attribute attr = self.class.statistic_attribute
delta = read_attribute(attr).to_i - attribute_before_last_save(attr).to_i delta = read_attribute(attr).to_i - attribute_before_last_save(attr).to_i
update_project_statistics(delta) schedule_update_project_statistic(delta)
schedule_namespace_aggregation_worker
end end
def update_project_statistics_attribute_changed? def update_project_statistics_attribute_changed?
...@@ -58,24 +57,35 @@ module UpdateProjectStatistics ...@@ -58,24 +57,35 @@ module UpdateProjectStatistics
end end
def update_project_statistics_after_destroy def update_project_statistics_after_destroy
update_project_statistics(-read_attribute(self.class.statistic_attribute).to_i) delta = -read_attribute(self.class.statistic_attribute).to_i
schedule_namespace_aggregation_worker schedule_update_project_statistic(delta)
end end
def project_destroyed? def project_destroyed?
project.pending_delete? project.pending_delete?
end end
def update_project_statistics(delta) def schedule_update_project_statistic(delta)
ProjectStatistics.increment_statistic(project_id, self.class.project_statistics_name, delta) return if delta.zero?
end
if Feature.enabled?(:update_project_statistics_after_commit, default_enabled: true)
# Update ProjectStatistics after the transaction
run_after_commit do
ProjectStatistics.increment_statistic(
project_id, self.class.project_statistics_name, delta)
end
else
# Use legacy-way to update within transaction
ProjectStatistics.increment_statistic(
project_id, self.class.project_statistics_name, delta)
end
def schedule_namespace_aggregation_worker
run_after_commit do run_after_commit do
next if project.nil? next if project.nil?
Namespaces::ScheduleAggregationWorker.perform_async(project.namespace_id) Namespaces::ScheduleAggregationWorker.perform_async(
project.namespace_id)
end end
end end
end end
......
---
title: UpdateProjectStatistics updates after commit
merge_request: 20852
author:
type: performance
...@@ -19,8 +19,24 @@ describe Ci::JobArtifact do ...@@ -19,8 +19,24 @@ describe Ci::JobArtifact do
it_behaves_like 'having unique enum values' it_behaves_like 'having unique enum values'
it_behaves_like 'UpdateProjectStatistics' do context 'with update_project_statistics_after_commit enabled' do
subject { build(:ci_job_artifact, :archive, size: 106365) } before do
stub_feature_flags(update_project_statistics_after_commit: true)
end
it_behaves_like 'UpdateProjectStatistics' do
subject { build(:ci_job_artifact, :archive, size: 106365) }
end
end
context 'with update_project_statistics_after_commit disabled' do
before do
stub_feature_flags(update_project_statistics_after_commit: false)
end
it_behaves_like 'UpdateProjectStatistics' do
subject { build(:ci_job_artifact, :archive, size: 106365) }
end
end end
describe '.with_reports' do describe '.with_reports' 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