Commit d3ad2fb9 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'provide_correct_wal_for_sidekiq_client_middleware' into 'master'

SidekiqClientMiddleware should continue using primary if primary was already selected

See merge request gitlab-org/gitlab!62115
parents 12115b52 a54f8b68
......@@ -26,7 +26,7 @@ module Gitlab
return if worker_class.get_data_consistency == :always
if Session.current.performed_write?
if Session.current.use_primary?
job['database_write_location'] = load_balancer.primary_write_location
else
job['database_replica_location'] = load_balancer.host.database_replica_location
......
......@@ -55,7 +55,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqClientMiddleware do
context 'when write was not performed' do
before do
allow(Gitlab::Database::LoadBalancing::Session.current).to receive(:performed_write?).and_return(false)
allow(Gitlab::Database::LoadBalancing::Session.current).to receive(:use_primary?).and_return(false)
end
it 'passes database_replica_location' do
......@@ -69,7 +69,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqClientMiddleware do
context 'when write was performed' do
before do
allow(Gitlab::Database::LoadBalancing::Session.current).to receive(:performed_write?).and_return(true)
allow(Gitlab::Database::LoadBalancing::Session.current).to receive(:use_primary?).and_return(true)
end
it 'passes primary write location', :aggregate_failures do
......@@ -83,9 +83,9 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqClientMiddleware do
end
shared_examples_for 'database location was already provided' do |provided_database_location, other_location|
shared_examples_for 'does not set database location again' do |write_performed|
shared_examples_for 'does not set database location again' do |use_primary|
before do
allow(Gitlab::Database::LoadBalancing::Session.current).to receive(:performed_write?).and_return(write_performed)
allow(Gitlab::Database::LoadBalancing::Session.current).to receive(:use_primary?).and_return(use_primary)
end
it 'does not set database locations again' 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