diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /lib/gitlab/database/load_balancing/host.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) | |
download | gitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'lib/gitlab/database/load_balancing/host.rb')
-rw-r--r-- | lib/gitlab/database/load_balancing/host.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/gitlab/database/load_balancing/host.rb b/lib/gitlab/database/load_balancing/host.rb index 3e74b5ea727..4c5357ae8e3 100644 --- a/lib/gitlab/database/load_balancing/host.rb +++ b/lib/gitlab/database/load_balancing/host.rb @@ -29,11 +29,11 @@ module Gitlab @host = host @port = port @load_balancer = load_balancer - @pool = Database.create_connection_pool(LoadBalancing.pool_size, host, port) + @pool = load_balancer.create_replica_connection_pool(::Gitlab::Database::LoadBalancing.pool_size, host, port) @online = true @last_checked_at = Time.zone.now - interval = LoadBalancing.replica_check_interval + interval = ::Gitlab::Database::LoadBalancing.replica_check_interval @intervals = (interval..(interval * 2)).step(0.5).to_a end @@ -41,10 +41,10 @@ module Gitlab # # timeout - The time after which the pool should be forcefully # disconnected. - def disconnect!(timeout = 120) - start_time = Metrics::System.monotonic_time + def disconnect!(timeout: 120) + start_time = ::Gitlab::Metrics::System.monotonic_time - while (Metrics::System.monotonic_time - start_time) <= timeout + while (::Gitlab::Metrics::System.monotonic_time - start_time) <= timeout break if pool.connections.none?(&:in_use?) sleep(2) @@ -54,7 +54,7 @@ module Gitlab end def offline! - LoadBalancing::Logger.warn( + ::Gitlab::Database::LoadBalancing::Logger.warn( event: :host_offline, message: 'Marking host as offline', db_host: @host, @@ -72,14 +72,14 @@ module Gitlab refresh_status if @online - LoadBalancing::Logger.info( + ::Gitlab::Database::LoadBalancing::Logger.info( event: :host_online, message: 'Host is online after replica status check', db_host: @host, db_port: @port ) else - LoadBalancing::Logger.warn( + ::Gitlab::Database::LoadBalancing::Logger.warn( event: :host_offline, message: 'Host is offline after replica status check', db_host: @host, @@ -108,7 +108,7 @@ module Gitlab def replication_lag_below_threshold? if (lag_time = replication_lag_time) - lag_time <= LoadBalancing.max_replication_lag_time + lag_time <= ::Gitlab::Database::LoadBalancing.max_replication_lag_time else false end @@ -125,7 +125,7 @@ module Gitlab # only do this if we haven't replicated in a while so we only need # to connect to the primary when truly necessary. if (lag_size = replication_lag_size) - lag_size <= LoadBalancing.max_replication_difference + lag_size <= ::Gitlab::Database::LoadBalancing.max_replication_difference else false end |