Commit 28d49bcb authored by nmilojevic1's avatar nmilojevic1

Sticks to the primary if no location provided

- Fix specs for sidekiq server middleware
parent 79eff458
......@@ -30,6 +30,8 @@ module Gitlab
location = job['database_write_location'] || job['database_replica_location']
return true unless location
if replica_caught_up?(location)
job[:database_chosen] = 'replica'
false
......@@ -48,8 +50,6 @@ module Gitlab
end
def replica_caught_up?(location)
return true unless location
load_balancer.host.caught_up?(location)
end
end
......
......@@ -93,14 +93,14 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware do
context 'when database location is not set' do
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
let(:queue) { 'default' }
let(:redis_pool) { Sidekiq.redis_pool }
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 }
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