Commit 47c6e774 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'handle-errors-without-causes' into 'master'

Handle database connection errors without causes

See merge request gitlab-org/gitlab!68858
parents 9d96770a 36dd486c
...@@ -169,7 +169,11 @@ module Gitlab ...@@ -169,7 +169,11 @@ module Gitlab
when ActiveRecord::StatementInvalid, ActionView::Template::Error when ActiveRecord::StatementInvalid, ActionView::Template::Error
# After connecting to the DB Rails will wrap query errors using this # After connecting to the DB Rails will wrap query errors using this
# class. # class.
connection_error?(error.cause) if (cause = error.cause)
connection_error?(cause)
else
false
end
when *CONNECTION_ERRORS when *CONNECTION_ERRORS
true true
else else
......
...@@ -283,6 +283,12 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer, :request_store do ...@@ -283,6 +283,12 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer, :request_store do
expect(lb.connection_error?(error)).to eq(false) expect(lb.connection_error?(error)).to eq(false)
end end
it 'returns false for ActiveRecord errors without a cause' do
error = ActiveRecord::RecordNotUnique.new
expect(lb.connection_error?(error)).to eq(false)
end
end end
describe '#serialization_failure?' do describe '#serialization_failure?' 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