Fixed replication pgReplicationSlotQuery - now it's working correctly for replica and primary (#825)

Signed-off-by: Vadim Voitenko <vadim.voitenko@exness.com>
Co-authored-by: Vadim Voitenko <vadim.voitenko@exness.com>
This commit is contained in:
Vadim Voitenko 2023-06-27 16:47:33 +03:00 committed by GitHub
parent bf4e4fb6cc
commit 6a1bb59efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -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 {