Commit ff5599e1 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '345213-fix-loadbalancin-autoload' into 'master'

Fixes autoloading  in development environment for LoadBalancing constant

See merge request gitlab-org/gitlab!74129
parents 8bfdf308 f0ac3446
...@@ -66,7 +66,7 @@ module Gitlab ...@@ -66,7 +66,7 @@ module Gitlab
# times before using the primary instead. # times before using the primary instead.
will_retry = conflict_retried < @host_list.length * 3 will_retry = conflict_retried < @host_list.length * 3
LoadBalancing::Logger.warn( ::Gitlab::Database::LoadBalancing::Logger.warn(
event: :host_query_conflict, event: :host_query_conflict,
message: 'Query conflict on host', message: 'Query conflict on host',
conflict_retried: conflict_retried, conflict_retried: conflict_retried,
...@@ -91,7 +91,7 @@ module Gitlab ...@@ -91,7 +91,7 @@ module Gitlab
end end
end end
LoadBalancing::Logger.warn( ::Gitlab::Database::LoadBalancing::Logger.warn(
event: :no_secondaries_available, event: :no_secondaries_available,
message: 'No secondaries were available, using primary instead', message: 'No secondaries were available, using primary instead',
conflict_retried: conflict_retried, conflict_retried: conflict_retried,
......
...@@ -13,7 +13,7 @@ module Gitlab ...@@ -13,7 +13,7 @@ module Gitlab
job['load_balancing_strategy'] = strategy.to_s job['load_balancing_strategy'] = strategy.to_s
if use_primary?(strategy) if use_primary?(strategy)
Session.current.use_primary! ::Gitlab::Database::LoadBalancing::Session.current.use_primary!
elsif strategy == :retry elsif strategy == :retry
raise JobReplicaNotUpToDate, "Sidekiq job #{worker_class} JID-#{job['jid']} couldn't use the replica."\ raise JobReplicaNotUpToDate, "Sidekiq job #{worker_class} JID-#{job['jid']} couldn't use the replica."\
" Replica was not up to date." " Replica was not up to date."
...@@ -29,8 +29,8 @@ module Gitlab ...@@ -29,8 +29,8 @@ module Gitlab
private private
def clear def clear
LoadBalancing.release_hosts ::Gitlab::Database::LoadBalancing.release_hosts
Session.clear_session ::Gitlab::Database::LoadBalancing::Session.clear_session
end end
def use_primary?(strategy) def use_primary?(strategy)
...@@ -66,7 +66,7 @@ module Gitlab ...@@ -66,7 +66,7 @@ module Gitlab
def legacy_wal_location(job) def legacy_wal_location(job)
wal_location = job['database_write_location'] || job['database_replica_location'] wal_location = job['database_write_location'] || job['database_replica_location']
{ Gitlab::Database::MAIN_DATABASE_NAME.to_sym => wal_location } if wal_location { ::Gitlab::Database::MAIN_DATABASE_NAME.to_sym => wal_location } if wal_location
end end
def load_balancing_available?(worker_class) def load_balancing_available?(worker_class)
...@@ -90,7 +90,7 @@ module Gitlab ...@@ -90,7 +90,7 @@ module Gitlab
end end
def databases_in_sync?(wal_locations) def databases_in_sync?(wal_locations)
LoadBalancing.each_load_balancer.all? do |lb| ::Gitlab::Database::LoadBalancing.each_load_balancer.all? do |lb|
if (location = wal_locations[lb.name]) if (location = wal_locations[lb.name])
lb.select_up_to_date_host(location) lb.select_up_to_date_host(location)
else else
......
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