Skip to content
Snippets Groups Projects
Commit 1aaf30a1 authored by Stan Hu's avatar Stan Hu
Browse files

Merge branch 'ash.mckenzie/7904-geo-fix-attachment-replication' into 'master'

Geo: Disable backoff for file attachment types

See merge request gitlab-org/gitlab-ee!7826
parents fea9b6aa 0e8fa14e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -4,6 +4,16 @@ class FileDownloadDispatchWorker < Geo::Scheduler::Secondary::SchedulerWorker
 
private
 
# Cannot utilise backoff because there are no events currently being
# generated for uploads, LFS objects or CI job artifacts so we need to rely
# upon expensive DB queries to be executed in order to determine if there's
# work to do.
#
# Overrides Geo::Scheduler::SchedulerWorker#should_apply_backoff?
def should_apply_backoff?
false
end
def max_capacity
current_node.files_max_capacity
end
Loading
Loading
Loading
Loading
@@ -109,6 +109,10 @@ def over_time?
(Time.now.utc - start_time) >= run_time
end
 
def should_apply_backoff?
pending_resources.empty?
end
# rubocop: disable CodeReuse/ActiveRecord
def take_batch(*arrays, batch_size: db_retrieve_batch_size)
interleave(*arrays).uniq.compact.take(batch_size)
Loading
Loading
@@ -165,7 +169,7 @@ def update_jobs_in_progress
def update_pending_resources
if reload_queue?
@pending_resources = load_pending_resources
set_backoff_time! if @pending_resources.empty?
set_backoff_time! if should_apply_backoff?
end
end
 
Loading
Loading
Loading
Loading
@@ -308,18 +308,8 @@
context 'backoff time' do
let(:cache_key) { "#{described_class.name.underscore}:skip" }
 
it 'sets the back off time when there are no pending items' do
expect(Rails.cache).to receive(:write).with(cache_key, true, expires_in: 300.seconds).once
subject.perform
end
it 'does not perform Geo::FileDownloadWorker when the backoff time is set' do
create(:lfs_object, :with_file)
expect(Rails.cache).to receive(:read).with(cache_key).and_return(true)
expect(Geo::FileDownloadWorker).not_to receive(:perform_async)
it 'does not set the back off time when there are no pending items' do
expect(Rails.cache).not_to receive(:write).with(cache_key, true, expires_in: 300.seconds)
 
subject.perform
end
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