summaryrefslogtreecommitdiff
path: root/spec/models/postgresql
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-11-02 23:31:37 -0700
committerStan Hu <stanhu@gmail.com>2018-11-03 07:00:31 -0700
commitfd7f95ee7421f297e71f8fe81159b6d9df381e4c (patch)
tree6a6c8aca35fba80ca915318265950204cfe4fe4b /spec/models/postgresql
parent3cdf7c7ec137d7753bab7687b24c7c1cd880357b (diff)
downloadgitlab-ce-fd7f95ee7421f297e71f8fe81159b6d9df381e4c.tar.gz
Disable replication lag check for Aurora PostgreSQL databasessh-fix-issue-52176
Replication slots are not supported in Aurora. Attempting to check the lag results in the message: ``` ActiveRecord::StatementInvalid: PG::FeatureNotSupported: ERROR: Replication slots are currently not supported in Aurora : SELECT pg_xlog_location_diff(pg_current_xlog_insert_location(), restart_lsn)::... ``` To avoid breaking support for background migrations in Aurora, we just disable the check if we encounter this error. This change also now checks whether there are any replication slots present in the primary before checking the replication lag. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/52176
Diffstat (limited to 'spec/models/postgresql')
-rw-r--r--spec/models/postgresql/replication_slot_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/postgresql/replication_slot_spec.rb b/spec/models/postgresql/replication_slot_spec.rb
index 919a7526803..e100af7ddc7 100644
--- a/spec/models/postgresql/replication_slot_spec.rb
+++ b/spec/models/postgresql/replication_slot_spec.rb
@@ -3,7 +3,27 @@
require 'spec_helper'
describe Postgresql::ReplicationSlot, :postgresql do
+ describe '.in_use?' do
+ it 'returns true when replication slots are present' do
+ expect(described_class).to receive(:exists?).and_return(true)
+ expect(described_class.in_use?).to be_truthy
+ end
+
+ it 'returns false when replication slots are not present' do
+ expect(described_class.in_use?).to be_falsey
+ end
+
+ it 'returns false if the existence check is invalid' do
+ expect(described_class).to receive(:exists?).and_raise(ActiveRecord::StatementInvalid.new('PG::FeatureNotSupported'))
+ expect(described_class.in_use?).to be_falsey
+ end
+ end
+
describe '.lag_too_great?' do
+ before do
+ expect(described_class).to receive(:in_use?).and_return(true)
+ end
+
it 'returns true when replication lag is too great' do
expect(described_class)
.to receive(:pluck)