Skip to content
Merged
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
Fixed replication pgReplicationSlotQuery - now it's working correctly…
… for replica and primary

Signed-off-by: Vadim Voitenko <[email protected]>
  • Loading branch information
wwoytenko committed Jun 27, 2023
commit 465d843551224fb50c6349536667fa2f1941a8c4
11 changes: 7 additions & 4 deletions collector/pg_replication_slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ var (

pgReplicationSlotQuery = `SELECT
slot_name,
pg_current_wal_lsn() - '0/0' AS current_wal_lsn,
coalesce(confirmed_flush_lsn, '0/0') - '0/0',
CASE WHEN pg_is_in_recovery() THEN
pg_last_wal_receive_lsn() - '0/0'
ELSE
pg_current_wal_lsn() - '0/0'
END AS current_wal_lsn,
COALESCE(confirmed_flush_lsn, '0/0') - '0/0',
active
FROM
pg_replication_slots;`
FROM pg_replication_slots;`
)

func (PGReplicationSlotCollector) Update(ctx context.Context, instance *instance, ch chan<- prometheus.Metric) error {
Expand Down