Skip to content

Commit 3a710b7

Browse files
committed
Fixed replication pgReplicationSlotQuery - now it's working correctly for replica and primary
1 parent bf4e4fb commit 3a710b7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

collector/pg_replication_slot.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ var (
6666

6767
pgReplicationSlotQuery = `SELECT
6868
slot_name,
69-
pg_current_wal_lsn() - '0/0' AS current_wal_lsn,
70-
coalesce(confirmed_flush_lsn, '0/0') - '0/0',
69+
CASE
70+
WHEN pg_is_in_recovery() THEN pg_last_wal_receive_lsn() - '0/0'
71+
ELSE pg_current_wal_lsn() - '0/0' END AS current_wal_lsn,
72+
COALESCE(confirmed_flush_lsn, '0/0') - '0/0',
7173
active
72-
FROM
73-
pg_replication_slots;`
74+
FROM pg_replication_slots;`
7475
)
7576

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

0 commit comments

Comments
 (0)