Add pg_synchronized_standby_slots_invalid metric#19
Merged
Conversation
`synchronized_standby_slots` must be a subset of replication slots. However, it's possible to configure postgres so that is not true. This breaks replication, but worse than that, any queries that use parallel background workers will fail to execute. Add a `pg_synchronized_standby_slots_invalid` metric that is `0` when no slots are invalid, and then the metric size is the number of invalid slots to track and detect this. Does not include slot name as label/etc as this could cause unbounded series growth.
994f3aa to
f1c6ef2
Compare
frouioui
reviewed
Feb 16, 2026
| ) | ||
|
|
||
| synchronizedStandbySlotsQuery = ` | ||
| SELECT count(*) AS invalid_count |
Member
There was a problem hiding this comment.
I would also include the name of the offending slot(s), so that we can add it as a label, easier debugging.
Author
There was a problem hiding this comment.
think we can just include a query in the runbook I think, don't wanna cause metric explosion here.
frouioui
approved these changes
Feb 16, 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.
pg_synchronized_standby_slots_invalidgauge metric — counts slots listed in the PG17synchronized_standby_slotsGUC that don't exist as physical replication slotspg_is_in_recovery())Testing
Unit tests cover these cases