Commit 549e3f76 authored by Stan Hu's avatar Stan Hu

Fix EE load balancing crashing on Rails 5

Rails 5 added the `preparable` argument to `select_all`, which was added
to help prepared statement caching via
https://github.com/rails/rails/commit/2a56b2d90d4fed8548e3a1e7a7b206454858c872.

This argument is not needed by the load balancer since prepared
statements are disabled, but it needs to be present or a method
signature error is thrown.

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/8692
parent 9fcaabb8
...@@ -30,7 +30,7 @@ module Gitlab ...@@ -30,7 +30,7 @@ module Gitlab
read_using_load_balancer(:select, args) read_using_load_balancer(:select, args)
end end
def select_all(arel, name = nil, binds = []) def select_all(arel, name = nil, binds = [], preparable: nil)
if arel.respond_to?(:locked) && arel.locked if arel.respond_to?(:locked) && arel.locked
# SELECT ... FOR UPDATE queries should be sent to the primary. # SELECT ... FOR UPDATE queries should be sent to the primary.
write_using_load_balancer(:select_all, [arel, name, binds], write_using_load_balancer(:select_all, [arel, name, binds],
......
...@@ -12,6 +12,13 @@ describe Gitlab::Database::LoadBalancing::ConnectionProxy do ...@@ -12,6 +12,13 @@ describe Gitlab::Database::LoadBalancing::ConnectionProxy do
end end
describe '#select_all' do describe '#select_all' do
let(:override_proxy) { ActiveRecord::Base.connection.class }
# We can't use :Gitlab::Utils::Override because this method is dynamically prepended
it 'method signatures match', :rails5 do
expect(proxy.method(:select_all).parameters).to eq(override_proxy.instance_method(:select_all).parameters)
end
describe 'using a SELECT query' do describe 'using a SELECT query' do
it 'runs the query on a secondary' do it 'runs the query on a secondary' do
arel = double(:arel) arel = double(:arel)
......
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