docs(observability): cache evictions carry a reason label and are exported from startup - #2073
Merged
Conversation
…orted from startup
Contributor
✅ Pull with Spice PassedPassing checks:
|
Contributor
|
🚀 deployed to https://82842210.spiceai-org-website.pages.dev |
Contributor
|
🚀 deployed to https://6788227c.spiceai-org-website.pages.dev |
bjchambers
approved these changes
Aug 11, 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.
Summary
Two merged runtime PRs changed what the results-cache metrics report, and neither was reflected in the docs:
*_cache_evictionsgained areasonlabel and now counts invalidation (spiceai/spiceai#12791). moka'sRemovalCause::was_evictedcovers onlyExpiredandSize, which left out the cause that dominates an accelerated deployment:invalidate_entries_if— how a refresh or a DML write drops a table's entries — deliversExplicit. The counter is now splitsize/expired/invalidated. The same PR made every cache counter publish at zero duringCacheMetrics::init, because aLazyLockinstrument registers only on first deref, so a healthy runtime exported no eviction series at all — indistinguishable from a broken exporter or a bad scrape config.results_cache_stale_rejectionsis a new counter (spiceai/spiceai#12703) for lookups that found an entry but refused to serve it because a table the result read had since been invalidated. These are also counted as misses.The docs said
*_cache_evictionswas "Total number of cache evictions due to size or TTL limits" with no dimensions — which now under-counts by exactly the dominant cause and omits the label an operator needs to tell cache pressure from routine refresh invalidation.Changes
website/docs/features/observability/index.md:*_cache_evictionsrows (results_,search_results_,embeddings_) get the reason breakdown and areasondimension in place of—.results_cache_stale_rejectionsrow.website/docs/features/caching/index.md(the cross-page site — it carries its own metrics table and a sample/metricsscrape):*_cache_evictionsdescription updated, plus areasonvalue table and a note on whyinvalidatedis split out.results_cache_stale_rejectionsdocumented alongside its relationship toresults_cache_misses.Verified against
origin/trunk, not the merged diffs:EvictionReason::{Size,Expired,Invalidated}and itsKeyValue::new("reason", …)pluspublish_counters_at_zero()incrates/cache/src/metrics.rs; theRemovalCause→EvictionReasonmapping incrates/cache/src/lru_cache.rs; and the singleCachedQueryResult::record_stale_rejection()call site incrates/cache/src/lib.rs.Note for a reviewer (upstream, not fixed here)
Two things worth an upstream issue rather than a docs change:
EVICTIONS.with_description()string ontrunkreads "Entries dropped by table invalidation are counted by the invalidations metric instead" — but no*_cache_invalidationsmetric exists anywhere incrates/, andeviction_reason()still mapsRemovalCause::ExplicittoEvictionReason::Invalidated. The description (exported as Prometheus HELP text) contradicts the code; the docs here follow the code. The sample scrape incaching/index.mdtherefore shows a shortened HELP line rather than reproducing that sentence.search_results_cache_stale_rejectionsandembeddings_cache_stale_rejectionsare registered and published at zero, but nothing increments them — only the SQL results cache has the validated-read path. They are intentionally left out of the tables rather than documented with a meaning they never carry.Source PRs
Versioned-docs propagation
Addition — vNext only. Both commits post-date
v2.1.4(tagged 2026-08-05) andgit tag --containsis empty for each, soversioned_docs/version-2.1.x/correctly documents the unlabelled counter.Test plan
cd website && npm run buildpasses (Docusaurus throws on broken links / undefined tags)