Commit 369dbc7c authored by Catalin Irimie's avatar Catalin Irimie

Prevent Git operations from checking replication lag on non-Geo sites

We were checking if the database is read only, and verifying the
replication lag, however with the addition of maintenance mode, the
read only check is also true when maintenance mode is enabled.

The problem with only using the read only check is two-fold:
unnecessary replication lag queries, when the current site is not
a secondary, as maintenance mode doesn't pause any DB operations;
and breaking databases that don't support the standard replication
functions to check the lag (i.e. Aurora).

Changelog: fixed
EE: true
parent 61ea24bf
...@@ -55,7 +55,8 @@ module EE ...@@ -55,7 +55,8 @@ module EE
end end
def current_replication_lag_message def current_replication_lag_message
return if ::Gitlab::Database.read_write? || current_replication_lag == 0 return unless ::Gitlab::Geo.secondary?
return if current_replication_lag == 0
"Current replication lag: #{current_replication_lag} seconds" "Current replication lag: #{current_replication_lag} seconds"
end end
......
...@@ -331,6 +331,20 @@ RSpec.describe Gitlab::GitAccess do ...@@ -331,6 +331,20 @@ RSpec.describe Gitlab::GitAccess do
context 'git pull' do context 'git pull' do
it { expect { pull_changes }.not_to raise_error } it { expect { pull_changes }.not_to raise_error }
context 'for non-Geo with maintenance mode' do
before do
stub_maintenance_mode_setting(true)
end
it 'does not return a replication lag message nor call the lag check' do
allow_next_instance_of(Gitlab::Geo::HealthCheck) do |instance|
expect(instance).not_to receive(:db_replication_lag_seconds)
end
expect(pull_changes.console_messages).to be_empty
end
end
context 'for a secondary' do context 'for a secondary' do
let(:current_replication_lag) { nil } let(:current_replication_lag) { nil }
......
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