summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2019-07-31 08:50:36 -0500
committerMayra Cabrera <mcabrera@gitlab.com>2019-07-31 08:53:29 -0500
commit976812afcf37168f5853f80b290c392ac0a7f3d4 (patch)
tree867a0e94e56be67538f3b70e2a88268e5b2f0773
parentbea3d730c2257d5c5e4f2539f4e4b1b81be84250 (diff)
downloadgitlab-ce-mc-reduce-namespaces-lease-time.tar.gz
Hardcodes namespaces lease timing value to 1.5hmc-reduce-namespaces-lease-time
After measuring the response and performance of the workers on https://gitlab.com/gitlab-org/gitlab-ce/issues/64092, we've decided 1.5 is fine for now. The time can be decreased later in the future when enforcing the quota limits Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/64092
-rw-r--r--app/models/namespace/aggregation_schedule.rb14
-rw-r--r--spec/models/namespace/aggregation_schedule_spec.rb34
2 files changed, 3 insertions, 45 deletions
diff --git a/app/models/namespace/aggregation_schedule.rb b/app/models/namespace/aggregation_schedule.rb
index 0bef352cf24..61a7eb4b576 100644
--- a/app/models/namespace/aggregation_schedule.rb
+++ b/app/models/namespace/aggregation_schedule.rb
@@ -6,21 +6,13 @@ class Namespace::AggregationSchedule < ApplicationRecord
self.primary_key = :namespace_id
- DEFAULT_LEASE_TIMEOUT = 3.hours
+ DEFAULT_LEASE_TIMEOUT = 1.5.hours.to_i
REDIS_SHARED_KEY = 'gitlab:update_namespace_statistics_delay'.freeze
belongs_to :namespace
after_create :schedule_root_storage_statistics
- def self.delay_timeout
- redis_timeout = Gitlab::Redis::SharedState.with do |redis|
- redis.get(REDIS_SHARED_KEY)
- end
-
- redis_timeout.nil? ? DEFAULT_LEASE_TIMEOUT : redis_timeout.to_i
- end
-
def schedule_root_storage_statistics
run_after_commit_or_now do
try_obtain_lease do
@@ -28,7 +20,7 @@ class Namespace::AggregationSchedule < ApplicationRecord
.perform_async(namespace_id)
Namespaces::RootStatisticsWorker
- .perform_in(self.class.delay_timeout, namespace_id)
+ .perform_in(DEFAULT_LEASE_TIMEOUT, namespace_id)
end
end
end
@@ -37,7 +29,7 @@ class Namespace::AggregationSchedule < ApplicationRecord
# Used by ExclusiveLeaseGuard
def lease_timeout
- self.class.delay_timeout
+ DEFAULT_LEASE_TIMEOUT
end
# Used by ExclusiveLeaseGuard
diff --git a/spec/models/namespace/aggregation_schedule_spec.rb b/spec/models/namespace/aggregation_schedule_spec.rb
index 0f1283717e0..38bf8089411 100644
--- a/spec/models/namespace/aggregation_schedule_spec.rb
+++ b/spec/models/namespace/aggregation_schedule_spec.rb
@@ -7,24 +7,6 @@ RSpec.describe Namespace::AggregationSchedule, :clean_gitlab_redis_shared_state,
it { is_expected.to belong_to :namespace }
- describe '.delay_timeout' do
- context 'when timeout is set on redis' do
- it 'uses personalized timeout' do
- Gitlab::Redis::SharedState.with do |redis|
- redis.set(described_class::REDIS_SHARED_KEY, 1.hour)
- end
-
- expect(described_class.delay_timeout).to eq(1.hour)
- end
- end
-
- context 'when timeout is not set on redis' do
- it 'uses default timeout' do
- expect(described_class.delay_timeout).to eq(3.hours)
- end
- end
- end
-
describe '#schedule_root_storage_statistics' do
let(:namespace) { create(:namespace) }
let(:aggregation_schedule) { namespace.build_aggregation_schedule }
@@ -87,21 +69,5 @@ RSpec.describe Namespace::AggregationSchedule, :clean_gitlab_redis_shared_state,
aggregation_schedule.schedule_root_storage_statistics
end
end
-
- context 'with a personalized lease timeout' do
- before do
- Gitlab::Redis::SharedState.with do |redis|
- redis.set(described_class::REDIS_SHARED_KEY, 1.hour)
- end
- end
-
- it 'uses a personalized time' do
- expect(Namespaces::RootStatisticsWorker)
- .to receive(:perform_in)
- .with(1.hour, aggregation_schedule.namespace_id)
-
- aggregation_schedule.save!
- end
- end
end
end