Skip to content

Commit

Permalink
feat: added replication status for v10+
Browse files Browse the repository at this point in the history
  • Loading branch information
3manuek committed Jul 24, 2023
1 parent 9b5ad71 commit 8eecac0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions sql/Replication/Streaming/leader_replication_status_v10+.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- Only for getting the status of those pids for streaming replication.
--
SELECT client_addr,
client_hostname,
client_port,
rs.slot_name,
rs.slot_type,
state,
pg_wal_lsn_diff(pg_current_wal_flush_lsn(), flush_lsn), --in bytes
pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_flush_lsn(), flush_lsn)),
pg_wal_lsn_diff(pg_current_wal_lsn(), write_lsn) as fromCurrentToWriteLSN, --in bytes
pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), write_lsn)) as fromCurrentToWriteLSN_pretty,
write_lsn, sent_lsn, flush_lsn, replay_lsn,
write_lag, flush_lag, replay_lag,
rs.restart_lsn, rs.confirmed_flush_lsn,
sync_state, sync_priority
FROM pg_stat_replication sr JOIN pg_replication_slots rs
ON (sr.pid = rs.active_pid)
WHERE rs.slot_type = 'physical';

0 comments on commit 8eecac0

Please sign in to comment.