Commit a5c0a3e8 authored by Stan Hu's avatar Stan Hu

Merge branch '3453-remove-geo-repository-sync-backoff' into 'master'

Remove the backoff delay from Geo repository sync

Closes #3453

See merge request gitlab-org/gitlab-ee!3009
parents 131e1db5 9110e558
module Geo module Geo
class RepositorySyncWorker < Geo::BaseSchedulerWorker class RepositorySyncWorker < Geo::BaseSchedulerWorker
BACKOFF_DELAY = 5.minutes
MAX_CAPACITY = 25 MAX_CAPACITY = 25
private private
...@@ -10,7 +9,7 @@ module Geo ...@@ -10,7 +9,7 @@ module Geo
end end
def schedule_job(project_id) def schedule_job(project_id)
job_id = Geo::ProjectSyncWorker.perform_in(BACKOFF_DELAY, project_id, Time.now) job_id = Geo::ProjectSyncWorker.perform_async(project_id, Time.now)
{ id: project_id, job_id: job_id } if job_id { id: project_id, job_id: job_id } if job_id
end end
......
---
title: Remove the backoff delay from Geo repository sync
merge_request: 3009
author:
type: changed
...@@ -16,7 +16,7 @@ describe Geo::RepositorySyncWorker, :postgresql do ...@@ -16,7 +16,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
end end
it 'performs Geo::ProjectSyncWorker for each project' do it 'performs Geo::ProjectSyncWorker for each project' do
expect(Geo::ProjectSyncWorker).to receive(:perform_in).twice.and_return(spy) expect(Geo::ProjectSyncWorker).to receive(:perform_async).twice.and_return(spy)
subject.perform subject.perform
end end
...@@ -25,7 +25,7 @@ describe Geo::RepositorySyncWorker, :postgresql do ...@@ -25,7 +25,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
create(:geo_project_registry, :sync_failed, project: project_in_synced_group) create(:geo_project_registry, :sync_failed, project: project_in_synced_group)
create(:geo_project_registry, :synced, project: unsynced_project) create(:geo_project_registry, :synced, project: unsynced_project)
expect(Geo::ProjectSyncWorker).to receive(:perform_in).once.and_return(spy) expect(Geo::ProjectSyncWorker).to receive(:perform_async).once.and_return(spy)
subject.perform subject.perform
end end
...@@ -35,7 +35,7 @@ describe Geo::RepositorySyncWorker, :postgresql do ...@@ -35,7 +35,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
create(:geo_project_registry, :synced, project: unsynced_project) create(:geo_project_registry, :synced, project: unsynced_project)
create(:geo_project_registry, :synced, :wiki_dirty) create(:geo_project_registry, :synced, :wiki_dirty)
expect(Geo::ProjectSyncWorker).to receive(:perform_in).twice.and_return(spy) expect(Geo::ProjectSyncWorker).to receive(:perform_async).twice.and_return(spy)
subject.perform subject.perform
end end
...@@ -43,7 +43,7 @@ describe Geo::RepositorySyncWorker, :postgresql do ...@@ -43,7 +43,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
it 'does not perform Geo::ProjectSyncWorker when no geo database is configured' do it 'does not perform Geo::ProjectSyncWorker when no geo database is configured' do
allow(Gitlab::Geo).to receive(:geo_database_configured?) { false } allow(Gitlab::Geo).to receive(:geo_database_configured?) { false }
expect(Geo::ProjectSyncWorker).not_to receive(:perform_in) expect(Geo::ProjectSyncWorker).not_to receive(:perform_async)
subject.perform subject.perform
end end
...@@ -51,7 +51,7 @@ describe Geo::RepositorySyncWorker, :postgresql do ...@@ -51,7 +51,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
it 'does not perform Geo::ProjectSyncWorker when not running on a secondary' do it 'does not perform Geo::ProjectSyncWorker when not running on a secondary' do
allow(Gitlab::Geo).to receive(:secondary?) { false } allow(Gitlab::Geo).to receive(:secondary?) { false }
expect(Geo::ProjectSyncWorker).not_to receive(:perform_in) expect(Geo::ProjectSyncWorker).not_to receive(:perform_async)
subject.perform subject.perform
end end
...@@ -59,7 +59,7 @@ describe Geo::RepositorySyncWorker, :postgresql do ...@@ -59,7 +59,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
it 'does not perform Geo::ProjectSyncWorker when node is disabled' do it 'does not perform Geo::ProjectSyncWorker when node is disabled' do
allow_any_instance_of(GeoNode).to receive(:enabled?) { false } allow_any_instance_of(GeoNode).to receive(:enabled?) { false }
expect(Geo::ProjectSyncWorker).not_to receive(:perform_in) expect(Geo::ProjectSyncWorker).not_to receive(:perform_async)
subject.perform subject.perform
end end
...@@ -70,8 +70,8 @@ describe Geo::RepositorySyncWorker, :postgresql do ...@@ -70,8 +70,8 @@ describe Geo::RepositorySyncWorker, :postgresql do
end end
it 'does not perform Geo::ProjectSyncWorker for projects that do not belong to selected namespaces to replicate' do it 'does not perform Geo::ProjectSyncWorker for projects that do not belong to selected namespaces to replicate' do
expect(Geo::ProjectSyncWorker).to receive(:perform_in) expect(Geo::ProjectSyncWorker).to receive(:perform_async)
.with(300, project_in_synced_group.id, within(1.minute).of(Time.now)) .with(project_in_synced_group.id, within(1.minute).of(Time.now))
.once .once
.and_return(spy) .and_return(spy)
...@@ -82,8 +82,8 @@ describe Geo::RepositorySyncWorker, :postgresql do ...@@ -82,8 +82,8 @@ describe Geo::RepositorySyncWorker, :postgresql do
create(:geo_project_registry, :synced, :repository_dirty, project: project_in_synced_group) create(:geo_project_registry, :synced, :repository_dirty, project: project_in_synced_group)
create(:geo_project_registry, :synced, :repository_dirty, project: unsynced_project) create(:geo_project_registry, :synced, :repository_dirty, project: unsynced_project)
expect(Geo::ProjectSyncWorker).to receive(:perform_in) expect(Geo::ProjectSyncWorker).to receive(:perform_async)
.with(300, project_in_synced_group.id, within(1.minute).of(Time.now)) .with(project_in_synced_group.id, within(1.minute).of(Time.now))
.once .once
.and_return(spy) .and_return(spy)
...@@ -105,8 +105,8 @@ describe Geo::RepositorySyncWorker, :postgresql do ...@@ -105,8 +105,8 @@ describe Geo::RepositorySyncWorker, :postgresql do
it 'tries to sync every project' do it 'tries to sync every project' do
project_list.each do |project| project_list.each do |project|
expect(Geo::ProjectSyncWorker) expect(Geo::ProjectSyncWorker)
.to receive(:perform_in) .to receive(:perform_async)
.with(anything, project.id, anything) .with(project.id, anything)
.at_least(:once) .at_least(:once)
.and_call_original .and_call_original
end end
......
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