Repository navigation
feat(metrics): report the attached synchronous standbys as observed - #11990
Merged
Merged
Conversation
4 tasks done
Contributor
Author
|
/test |
Contributor
|
@gbartolini, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/45129380615 |
Member
|
/test |
Contributor
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/45193120755 |
leonardoce
force-pushed
the
dev/11309
branch
2 times, most recently
from
November 24, 2026 08:46
bd8bbe4 to
ca0e396
Compare
leonardoce
force-pushed
the
dev/11309-b
branch
from
November 24, 2026 10:51
82689a9 to
05c8dff
Compare
Contributor
|
/time |
Contributor
|
/test |
Contributor
|
@leonardoce, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/45381009078 |
The `observed` value of `cnpg_collector_sync_replicas` was the number parsed from `synchronous_standby_names`, so it described what was requested and kept reporting a healthy value while commits were blocked waiting for standbys that were down. Count instead the standbys attached to the primary with a `sync` or `quorum` state in `pg_stat_replication`. With quorum-based replication every attached candidate is reported as `quorum`, so the value can be higher than the expected number, and `observed < expected` is the condition to alert on. Deprecate the `min` and `max` values, which are removed in 1.33.0, along with the legacy synchronous replication method they come from. Until then they stay populated with both configuration methods. Document the meaning of the `expected`, `observed`, `min` and `max` values and the recommended alert in the monitoring page, and the changes in the upgrade notes. Closes #11309 Assisted-by: Claude Signed-off-by: Gabriele Bartolini <[email protected]>
The recommended alert compared the `observed` and `expected` values of `cnpg_collector_sync_replicas` without ignoring the `value` label that tells them apart, so the two sides never matched and the alert could not fire. Match them with `ignoring(value)`. State that only the primary exposes `observed`, while every instance exposes the other values, and that with the legacy method `expected` never exceeds the number of ready replicas, so the alert does not fire when replicas are down. Signed-off-by: Armando Ruocco <[email protected]>
When a cluster is turned into a replica cluster, its primary becomes a standby without restarting the instance manager. The `observed` value of `cnpg_collector_sync_replicas` is only refreshed on a primary, so the instance kept exposing the last value it had collected. Remove the value when the instance is not a primary. Signed-off-by: Armando Ruocco <[email protected]>
Move the metrics collected only on a primary into their own function, so that a unit test can drive it, and verify that the `observed` value of `cnpg_collector_sync_replicas` is no longer exposed once the instance has become a standby. Signed-off-by: Armando Ruocco <[email protected]>
leonardoce
force-pushed
the
dev/11309-b
branch
from
November 24, 2026 13:34
05c8dff to
9826aec
Compare
leonardoce
approved these changes
Nov 24, 2026
armru
approved these changes
Nov 24, 2026
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.
The
observedvalue ofcnpg_collector_sync_replicaswas the number parsed fromsynchronous_standby_names, so it described what was requested and kept reporting a healthy value while commits were blocked waiting for standbys that were down.Count instead the standbys attached to the primary with a
syncorquorumstate inpg_stat_replication. With quorum-based replication every attached candidate is reported asquorum, so the value can be higher than the expected number, andobserved < expectedis the condition to alert on.Deprecate the
minandmaxvalues, which are removed in 1.33.0, along with the legacy synchronous replication method they come from. Until then they stay populated with both configuration methods.Document the meaning of the
expected,observed,minandmaxvalues and the recommended alert in the monitoring page, and the changes in the upgrade notes.Closes #11309
Assisted-by: Claude