Skip to content

Commit 061e4c6

Browse files
committed
Replication slots
1 parent a0d9034 commit 061e4c6

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

scripts/pg_database_activity.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,16 @@ if [[ ${#replication_status} >0 ]]; then
191191

192192
echo -e "${GREENLIGHT}Replication status:${NC}"
193193
$PG_BIN/psql -c "
194-
SELECT client_addr AS client_addr, usename AS username, application_name AS app_name, pid, state, sync_state AS MODE,
195-
(pg_wal_lsn_diff(pg_current_wal_lsn(), sent_lsn) / 1024)::int AS sending_lag, -- sending_lag (network problems)
196-
(pg_wal_lsn_diff(sent_lsn, flush_lsn) / 1024)::int AS receiving_lag, -- receiving_lag
197-
(pg_wal_lsn_diff(sent_lsn, write_lsn) / 1024)::int AS WRITE, -- disks problems
198-
(pg_wal_lsn_diff(write_lsn, flush_lsn) / 1024)::int AS FLUSH, -- disks problems
199-
(pg_wal_lsn_diff(flush_lsn, replay_lsn) / 1024)::int AS replaying_lag, -- replaying_lag (disks/CPU problems)
200-
(pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn))::int / 1024 AS total_lag
201-
FROM pg_stat_replication;" | grep -v row
194+
SELECT r.client_addr AS client_addr, r.usename AS username, r.application_name AS app_name, r.pid, s.slot_name, s.slot_type, r.state, r.sync_state AS MODE,
195+
(pg_wal_lsn_diff(pg_current_wal_lsn(), r.sent_lsn) / 1024)::int AS send_lag, -- sending_lag (network problems)
196+
(pg_wal_lsn_diff(r.sent_lsn, r.flush_lsn) / 1024)::int AS receive_lag, -- receiving_lag
197+
(pg_wal_lsn_diff(r.sent_lsn, r.write_lsn) / 1024)::int AS WRITE, -- disks problems
198+
(pg_wal_lsn_diff(r.write_lsn, r.flush_lsn) / 1024)::int AS FLUSH, -- disks problems
199+
(pg_wal_lsn_diff(r.flush_lsn, r.replay_lsn) / 1024)::int AS replay_lag, -- replaying_lag (disks/CPU problems)
200+
(pg_wal_lsn_diff(pg_current_wal_lsn(), r.replay_lsn))::int / 1024 AS total_lag
201+
FROM pg_stat_replication r, pg_replication_slots s
202+
WHERE r.pid = s.active_pid;" | grep -v row
203+
202204
PG_LOG_LINES=$((PG_LOG_LINES-5))
203205

204206
fi

scripts/pg_database_status.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ echo
1818

1919
echo "PostgreSQL replication service (receiver). Works on Replica server:"
2020
ps ax | grep -v grep | grep receiver
21+
echo
22+
23+
echo "PostgreSQL logical replication service (worker). Works on Replica server:"
24+
ps ax | grep -v grep | grep "logical replication worker"

0 commit comments

Comments
 (0)