Fix invalid and redundant indexes stats in schemas collector - #391
Open
boosterKRD wants to merge 3 commits into
Open
boosterKRD wants to merge 3 commits into
boosterKRD wants to merge 3 commits into
Conversation
- invalid indexes are already reported by the invalid indexes metric - indexes locked in AccessExclusiveLock mode are skipped to prevent blocking on pg_relation_size()
Owner
|
Hi, @boosterKRD Thank's for the improvement, I will look into it and test it soon. |
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.
Two problems in the schemas collector:
Collector hangs on a locked index. pg_relation_size() opens the index with AccessShareLock and waits until an AccessExclusiveLock (DROP INDEX, REINDEX, etc.) is released. The guard added in Query hang risk: AND granted in AccessExclusiveLock filter is insufficient #329 covered postgres_indexes.go and postgres_tables.go, but postgres_schema.go calls pg_relation_size() without it.
Flapping metrics during concurrent index builds. REINDEX CONCURRENTLY creates a transient *_ccnew/ccold index which stays invalid until the command finishes. It is reported as an invalid index (and its copy — as a redundant one), and the series disappears when the rebuild completes. Indexes left over after failed concurrent builds are still reported — no progress entry is associated with them anymore.