Commit 6ea555fa authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fix query error on Rails 6.1

Rails 6.1 does not allow arbitrary strings in ActiveRecord methods so we
need to wrap this in `Arel.sql`
parent 4a85d66f
......@@ -27,7 +27,7 @@ module Postgresql
# We force the use of a transaction here so the query always goes to the
# primary, even when using the EE DB load balancer.
sizes = transaction { pluck(lag_function) }
sizes = transaction { pluck(Arel.sql(lag_function)) }
too_great = sizes.compact.count { |size| size >= max }
# If too many replicas are falling behind too much, the availability of a
......
......@@ -24,6 +24,10 @@ RSpec.describe Postgresql::ReplicationSlot do
expect(described_class).to receive(:in_use?).and_return(true)
end
it 'does not raise an exception' do
expect { described_class.lag_too_great? }.not_to raise_error
end
it 'returns true when replication lag is too great' do
expect(described_class)
.to receive(:pluck)
......
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