Skip to content
Snippets Groups Projects
Commit 45a05a8b authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 284ae7dd
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -170,8 +170,8 @@ group :unicorn do
end
 
group :puma do
gem 'puma', '~> 3.12', require: false
gem 'puma_worker_killer', require: false
gem 'puma', '~> 4.3.0', require: false
gem 'puma_worker_killer', '~> 0.1.1', require: false
gem 'rack-timeout', require: false
end
 
Loading
Loading
Loading
Loading
@@ -749,10 +749,11 @@ GEM
pry-rails (0.3.6)
pry (>= 0.10.4)
public_suffix (3.1.1)
puma (3.12.0)
puma_worker_killer (0.1.0)
puma (4.3.0)
nio4r (~> 2.0)
puma_worker_killer (0.1.1)
get_process_mem (~> 0.2)
puma (>= 2.7, < 4)
puma (>= 2.7, < 5)
pyu-ruby-sasl (0.0.3.3)
raabro (1.1.6)
rack (2.0.7)
Loading
Loading
@@ -1280,8 +1281,8 @@ DEPENDENCIES
prometheus-client-mmap (~> 0.9.10)
pry-byebug (~> 3.5.1)
pry-rails (~> 0.3.4)
puma (~> 3.12)
puma_worker_killer
puma (~> 4.3.0)
puma_worker_killer (~> 0.1.1)
rack (~> 2.0.7)
rack-attack (~> 6.2.0)
rack-cors (~> 1.0.0)
Loading
Loading
Loading
Loading
@@ -49,8 +49,7 @@ module UpdateProjectStatistics
attr = self.class.statistic_attribute
delta = read_attribute(attr).to_i - attribute_before_last_save(attr).to_i
 
update_project_statistics(delta)
schedule_namespace_aggregation_worker
schedule_update_project_statistic(delta)
end
 
def update_project_statistics_attribute_changed?
Loading
Loading
@@ -58,24 +57,35 @@ module UpdateProjectStatistics
end
 
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
 
def project_destroyed?
project.pending_delete?
end
 
def update_project_statistics(delta)
ProjectStatistics.increment_statistic(project_id, self.class.project_statistics_name, delta)
end
def schedule_update_project_statistic(delta)
return if delta.zero?
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
next if project.nil?
 
Namespaces::ScheduleAggregationWorker.perform_async(project.namespace_id)
Namespaces::ScheduleAggregationWorker.perform_async(
project.namespace_id)
end
end
end
Loading
Loading
---
title: UpdateProjectStatistics updates after commit
merge_request: 20852
author:
type: performance
Loading
Loading
@@ -19,8 +19,24 @@ describe Ci::JobArtifact do
 
it_behaves_like 'having unique enum values'
 
it_behaves_like 'UpdateProjectStatistics' do
subject { build(:ci_job_artifact, :archive, size: 106365) }
context 'with update_project_statistics_after_commit enabled' do
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
 
describe '.with_reports' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment