Commit 26679abb authored by Thong Kuah's avatar Thong Kuah

Log if a host is offline due to replication lag

parent 98abc0a0
---
title: Improve DB load balancing log to log host offline due to replication lag
merge_request: 15995
author:
type: changed
......@@ -78,6 +78,13 @@ module Gitlab
db_host: @host,
db_port: @port
)
else
LoadBalancing::Logger.warn(
event: :host_offline,
message: 'Host is offline after replica status check',
db_host: @host,
db_port: @port
)
end
@online
......
......@@ -124,6 +124,20 @@ describe Gitlab::Database::LoadBalancing::Host do
expect(host).to be_online
end
context 'and replica is not up to date' do
before do
expect(host).to receive(:replica_is_up_to_date?).and_return(false)
end
it 'marks the host offline' do
expect(Gitlab::Database::LoadBalancing::Logger).to receive(:warn)
.with(hash_including(event: :host_offline))
.and_call_original
expect(host).not_to be_online
end
end
end
context 'when the replica is not online' 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