diff --git a/lib/pg/pglogical/client.rb b/lib/pg/pglogical/client.rb index 02225ec..3495ac7 100644 --- a/lib/pg/pglogical/client.rb +++ b/lib/pg/pglogical/client.rb @@ -215,8 +215,17 @@ def subscription_remove_replication_set(name, set_name) # slot_name # replication_sets # forward_origins + # remote_replication_lsn(Log Sequence Number) + # local_replication_lsn(Log Sequence Number) def subscription_show_status(name) - typed_exec("SELECT * FROM pglogical.show_subscription_status($1)", name).first.tap do |s| + sql = <<-SQL + SELECT sub.*, stat.remote_lsn AS remote_replication_lsn, stat.local_lsn AS local_replication_lsn + FROM pglogical.show_subscription_status($1) sub + JOIN pg_replication_origin_status stat + ON sub.slot_name = stat.external_id + SQL + + typed_exec(sql, name).first.tap do |s| s["replication_sets"] = s["replication_sets"][1..-2].split(",") s["forward_origins"] = s["forward_origins"][1..-2].split(",") end diff --git a/spec/replication_spec.rb b/spec/replication_spec.rb index 69f7354..963d7c4 100644 --- a/spec/replication_spec.rb +++ b/spec/replication_spec.rb @@ -86,6 +86,8 @@ def enable_nodes expect(sub_info["status"]).to eq("replicating") expect(sub_info["provider_dsn"]).to eq(source_dsn) expect(sub_info["replication_sets"]).to eq([replication_set_name]) + expect(sub_info["remote_replication_lsn"]).to match(%r{\h+/\h+}) + expect(sub_info["local_replication_lsn"]).to match(%r{\h+/\h+}) sub_list = target_connection.pglogical.subscriptions expect(sub_list.first).to eq(sub_info)