Commit 479ceff3 authored by Tiger Watson's avatar Tiger Watson

Merge branch '329183-stick-to-primary-if-no-location' into 'master'

Sticks to the primary if no location provided

See merge request gitlab-org/gitlab!60378
parents 3df9efbd 28d49bcb
...@@ -30,6 +30,8 @@ module Gitlab ...@@ -30,6 +30,8 @@ module Gitlab
location = job['database_write_location'] || job['database_replica_location'] location = job['database_write_location'] || job['database_replica_location']
return true unless location
if replica_caught_up?(location) if replica_caught_up?(location)
job[:database_chosen] = 'replica' job[:database_chosen] = 'replica'
false false
...@@ -48,8 +50,6 @@ module Gitlab ...@@ -48,8 +50,6 @@ module Gitlab
end end
def replica_caught_up?(location) def replica_caught_up?(location)
return true unless location
load_balancer.host.caught_up?(location) load_balancer.host.caught_up?(location)
end end
end end
......
...@@ -93,14 +93,14 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware do ...@@ -93,14 +93,14 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware do
context 'when database location is not set' do context 'when database location is not set' do
let(:job) { { 'job_id' => 'a180b47c-3fd6-41b8-81e9-34da61c3400e' } } let(:job) { { 'job_id' => 'a180b47c-3fd6-41b8-81e9-34da61c3400e' } }
it_behaves_like 'replica is up to date', nil it_behaves_like 'stick to the primary', nil
end end
end end
let(:queue) { 'default' } let(:queue) { 'default' }
let(:redis_pool) { Sidekiq.redis_pool } let(:redis_pool) { Sidekiq.redis_pool }
let(:worker) { worker_class.new } let(:worker) { worker_class.new }
let(:job) { { "job_id" => "a180b47c-3fd6-41b8-81e9-34da61c3400e" } } let(:job) { { "job_id" => "a180b47c-3fd6-41b8-81e9-34da61c3400e", 'database_replica_location' => '0/D525E3A8' } }
let(:block) { 10 } let(:block) { 10 }
before do before 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