Commit 83a91196 authored by Stan Hu's avatar Stan Hu

Merge branch 'load-balancing-connection-quoting' into 'master'

Fix DB LB errors when escaping input

See merge request gitlab-org/gitlab-ee!5481
parents ec49bf08 256709fd
---
title: Fix DB LB errors when escaping input
merge_request:
author:
type: fixed
......@@ -115,6 +115,8 @@ module Gitlab
SQL
row['diff'].to_i if row.any?
rescue *CONNECTION_ERRORS
nil
end
def primary_write_location
......@@ -142,6 +144,8 @@ module Gitlab
row = query_and_release(query)
row['result'] == 't'
rescue *CONNECTION_ERRORS
false
end
def query_and_release(sql)
......
......@@ -239,6 +239,14 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
expect(host.replication_lag_size).to be_nil
end
it 'returns nil when the database connection fails' do
allow(host)
.to receive(:connection)
.and_raise(ActionView::Template::Error.new('boom', StandardError.new))
expect(host.replication_lag_size).to be_nil
end
end
describe '#primary_write_location' do
......@@ -268,6 +276,14 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
expect(host.caught_up?('foo')).to eq(false)
end
it 'returns false when the connection fails' do
allow(host)
.to receive(:connection)
.and_raise(ActionView::Template::Error.new('boom', StandardError.new))
expect(host.caught_up?('foo')).to eq(false)
end
end
describe '#query_and_release' 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