Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HAMMER]Do not calculate backlog when subscription not active #19254

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions app/models/pglogical_subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,16 @@ def validate(new_connection_params = {})
end

def backlog
connection.xlog_location_diff(remote_node_lsn, remote_replication_lsn)
rescue PG::Error => e
_log.error(e.message)
nil
if status != "replicating"
_log.error("Is `#{dbname}` running on host `#{host}` and accepting TCP/IP connections on port #{port} ?")
return nil
end
begin
connection.xlog_location_diff(remote_node_lsn, remote_replication_lsn)
rescue PG::Error => e
_log.error(e.message)
nil
end
end

# translate the output from the pglogical stored proc to our object columns
Expand Down
7 changes: 7 additions & 0 deletions spec/models/pglogical_subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -496,5 +496,12 @@

expect(described_class.first.backlog).to be nil
end

it 'does not attempt to calculate backlog and returns nil unless subscription status is "replicating"' do
allow(described_class).to receive(:status).and_return("down")

expect(remote_connection).not_to receive(:xlog_location)
expect(described_class.first.backlog).to be nil
end
end
end