Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.

Commit ff56fba

Browse files
authored
Merge pull request #8 from carbonin/add_replication_origin_info_to_subscription_status
Add the remote and local lsn to the subscription status
2 parents e6ff153 + fbec407 commit ff56fba

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

lib/pg/pglogical/client.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,17 @@ def subscription_remove_replication_set(name, set_name)
215215
# slot_name
216216
# replication_sets
217217
# forward_origins
218+
# remote_replication_lsn(Log Sequence Number)
219+
# local_replication_lsn(Log Sequence Number)
218220
def subscription_show_status(name)
219-
typed_exec("SELECT * FROM pglogical.show_subscription_status($1)", name).first.tap do |s|
221+
sql = <<-SQL
222+
SELECT sub.*, stat.remote_lsn AS remote_replication_lsn, stat.local_lsn AS local_replication_lsn
223+
FROM pglogical.show_subscription_status($1) sub
224+
JOIN pg_replication_origin_status stat
225+
ON sub.slot_name = stat.external_id
226+
SQL
227+
228+
typed_exec(sql, name).first.tap do |s|
220229
s["replication_sets"] = s["replication_sets"][1..-2].split(",")
221230
s["forward_origins"] = s["forward_origins"][1..-2].split(",")
222231
end

spec/replication_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def enable_nodes
8686
expect(sub_info["status"]).to eq("replicating")
8787
expect(sub_info["provider_dsn"]).to eq(source_dsn)
8888
expect(sub_info["replication_sets"]).to eq([replication_set_name])
89+
expect(sub_info["remote_replication_lsn"]).to match(%r{\h+/\h+})
90+
expect(sub_info["local_replication_lsn"]).to match(%r{\h+/\h+})
8991

9092
sub_list = target_connection.pglogical.subscriptions
9193
expect(sub_list.first).to eq(sub_info)

0 commit comments

Comments
 (0)