Skip to content

Fix invalid and redundant indexes stats in schemas collector - #391

Open
boosterKRD wants to merge 3 commits into
cherts:release/0.15from
boosterKRD:dev-fixed-schema-invalid-indexes
Open

boosterKRD wants to merge 3 commits into
cherts:release/0.15from
boosterKRD:dev-fixed-schema-invalid-indexes

Conversation

@boosterKRD

Copy link
Copy Markdown

Two problems in the schemas collector:

  1. 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.

  2. 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.

- invalid indexes are already reported by the invalid indexes metric
- indexes locked in AccessExclusiveLock mode are skipped to prevent blocking
  on pg_relation_size()
@cherts

cherts commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Hi, @boosterKRD

Thank's for the improvement, I will look into it and test it soon.

@boosterKRD boosterKRD changed the title Fix invalid and redundant indexes stats in schemas collector" Fix invalid and redundant indexes stats in schemas collector Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants