Skip to content

Error "WAL control functions cannot be executed during recovery" for replication collector #85

@s-kononenko

Description

@s-kononenko

Describe the bug
When using cascading replication, e.g. standby master

Steps to reproduce
Just use cascade physical replication:
leader -> replica1 -> replica2

Expected behavior
Expected replication metrics, such as lag on replica1

pgSCV startup options
Used example config.

Errors and Logs

2025-01-27 11:30:32 MSK [28058-1] 127.0.0.1(33670) pgscv@postgres ERROR:  recovery is in progress
2025-01-27 11:30:32 MSK [28058-2] 127.0.0.1(33670) pgscv@postgres HINT:  WAL control functions cannot be executed during recovery.
2025-01-27 11:30:32 MSK [28058-3] 127.0.0.1(33670) pgscv@postgres STATEMENT:  SELECT pid, coalesce(host(client_addr), '127.0.0.1') AS client_addr, coalesce(client_port, '0') AS client_port, usename AS user, application_name, state, pg_current_wal_lsn() - sent_lsn AS pending_lag_bytes, sent_lsn - write_lsn AS write_lag_bytes, write_lsn - flush_lsn AS flush_lag_bytes, flush_lsn - replay_lsn AS replay_lag_bytes, pg_current_wal_lsn() - replay_lsn AS total_lag_bytes, coalesce(extract(epoch from write_lag), 0) AS write_lag_seconds, coalesce(extract(epoch from flush_lag), 0) AS flush_lag_seconds, coalesce(extract(epoch from replay_lag), 0) AS replay_lag_seconds, coalesce(extract(epoch from write_lag+flush_lag+replay_lag), 0) AS total_lag_seconds FROM pg_stat_replication

Environment (please complete the following information):

  • Used OS (or Containers): Astra Linux 2.12.45
  • pgSCV version pgscv v0.9.7 6293eef905bc8bc01837d15fee666c5959697bbe-HEAD
  • pgSCV file info -rwxr-xr-x 1 root root 21591124 янв 15 11:49 /usr/local/bin/pgscv
  • PostgreSQL version PostgreSQL 13.9 on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit
  • Do PostgreSQL and pgSCV are running on the same host? Yes

Additional context
Found exactly the same issue for postgres-exporter
prometheus-community/postgres_exporter@e7fdba2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions