diff --git a/app/models/pglogical_subscription.rb b/app/models/pglogical_subscription.rb index 31a9c201283..1c5dd5e3628 100644 --- a/app/models/pglogical_subscription.rb +++ b/app/models/pglogical_subscription.rb @@ -102,6 +102,9 @@ def validate(new_connection_params = {}) def backlog connection.xlog_location_diff(remote_node_lsn, remote_replication_lsn) + rescue PG::Error => e + _log.error(e.message) + nil end # translate the output from the pglogical stored proc to our object columns diff --git a/spec/models/pglogical_subscription_spec.rb b/spec/models/pglogical_subscription_spec.rb index 81d894a700b..b967868f2a6 100644 --- a/spec/models/pglogical_subscription_spec.rb +++ b/spec/models/pglogical_subscription_spec.rb @@ -423,5 +423,11 @@ expect(described_class.first.backlog).to eq(12_120) end + + it "returns nill if error raised inside" do + expect(MiqRegionRemote).to receive(:with_remote_connection).and_raise(PG::Error) + + expect(described_class.first.backlog).to be nil + end end end