fix(metrics): skip pg_stat_archiver metrics on non-archiving standbys#9411
Merged
gbartolini merged 1 commit intomainfrom Dec 16, 2025
Merged
fix(metrics): skip pg_stat_archiver metrics on non-archiving standbys#9411gbartolini merged 1 commit intomainfrom
gbartolini merged 1 commit intomainfrom
Conversation
Contributor
|
❗ By default, the pull request is configured to backport to all release branches.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where PostgreSQL instances demoted from primary to standby retain stale pg_stat_archiver metrics, leading to false alerts on non-archiving standby nodes.
Key Changes:
- Added a
predicate_queryto pg_stat_archiver metrics collection that ensures metrics are only gathered from instances actively performing WAL archiving - The predicate correctly identifies primary instances and designated primary replicas (with archive_mode='always')
gbartolini
approved these changes
Dec 12, 2025
jbattiato
approved these changes
Dec 16, 2025
After a PostgreSQL instance is demoted from primary to standby, the pg_stat_archiver view retains stale data from when the instance was archiving WAL files. This causes misleading metrics and false alerts (e.g., "last archive age > 7 minutes") on standby nodes that do not actively archive WAL. This fix adds a predicate_query to the pg_stat_archiver metrics collection that only runs the query on instances that actually perform WAL archiving: - Primary instances (not in recovery) - Designated primary replicas (archive_mode='always' in replica clusters) Regular standby nodes will no longer export pg_stat_archiver metrics, preventing stale data from triggering false alerts. Fixes #9101 Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
mnencia
approved these changes
Dec 16, 2025
cnpg-bot
pushed a commit
that referenced
this pull request
Dec 16, 2025
…ys (#9411) After a PostgreSQL instance is demoted from primary to standby, the `pg_stat_archiver` view retains stale data from when the instance was archiving WAL files. This causes misleading metrics and false alerts (e.g., "last archive age > 7 minutes") on standby nodes that do not actively archive WAL. This fix adds a predicate_query to the `pg_stat_archiver` metrics collection that only runs the query on instances that actually perform WAL archiving: - Primary instances (not in recovery) - Designated primary replicas (archive_mode='always' in replica clusters) Regular standby nodes will no longer export `pg_stat_archiver` metrics, preventing stale data from triggering false alerts. Fixes #9101 Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com> (cherry picked from commit e2d6bd0)
cnpg-bot
pushed a commit
that referenced
this pull request
Dec 16, 2025
…ys (#9411) After a PostgreSQL instance is demoted from primary to standby, the `pg_stat_archiver` view retains stale data from when the instance was archiving WAL files. This causes misleading metrics and false alerts (e.g., "last archive age > 7 minutes") on standby nodes that do not actively archive WAL. This fix adds a predicate_query to the `pg_stat_archiver` metrics collection that only runs the query on instances that actually perform WAL archiving: - Primary instances (not in recovery) - Designated primary replicas (archive_mode='always' in replica clusters) Regular standby nodes will no longer export `pg_stat_archiver` metrics, preventing stale data from triggering false alerts. Fixes #9101 Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com> (cherry picked from commit e2d6bd0)
cnpg-bot
pushed a commit
that referenced
this pull request
Dec 16, 2025
…ys (#9411) After a PostgreSQL instance is demoted from primary to standby, the `pg_stat_archiver` view retains stale data from when the instance was archiving WAL files. This causes misleading metrics and false alerts (e.g., "last archive age > 7 minutes") on standby nodes that do not actively archive WAL. This fix adds a predicate_query to the `pg_stat_archiver` metrics collection that only runs the query on instances that actually perform WAL archiving: - Primary instances (not in recovery) - Designated primary replicas (archive_mode='always' in replica clusters) Regular standby nodes will no longer export `pg_stat_archiver` metrics, preventing stale data from triggering false alerts. Fixes #9101 Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com> (cherry picked from commit e2d6bd0)
4 tasks
Contributor
|
Should we decide to loosen the requirement, I implemented #9475 to align the E2e tests. |
mnencia
pushed a commit
that referenced
this pull request
Jan 20, 2026
…ys (#9411) After a PostgreSQL instance is demoted from primary to standby, the `pg_stat_archiver` view retains stale data from when the instance was archiving WAL files. This causes misleading metrics and false alerts (e.g., "last archive age > 7 minutes") on standby nodes that do not actively archive WAL. This fix adds a predicate_query to the `pg_stat_archiver` metrics collection that only runs the query on instances that actually perform WAL archiving: - Primary instances (not in recovery) - Designated primary replicas (archive_mode='always' in replica clusters) Regular standby nodes will no longer export `pg_stat_archiver` metrics, preventing stale data from triggering false alerts. Fixes #9101 Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com> (cherry picked from commit e2d6bd0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After a PostgreSQL instance is demoted from primary to standby, the pg_stat_archiver view retains stale data from when the instance was archiving WAL files. This causes misleading metrics and false alerts (e.g., "last archive age > 7 minutes") on standby nodes that do not actively archive WAL.
This fix adds a predicate_query to the pg_stat_archiver metrics collection that only runs the query on instances that actually perform WAL archiving:
Regular standby nodes will no longer export pg_stat_archiver metrics, preventing stale data from triggering false alerts.
Fixes #9101