Skip to content

fix(query-orchestrator): align pre-aggregation refresh key cache TTL with renewalThreshold#10993

Open
igorferst wants to merge 1 commit into
cube-js:masterfrom
igorferst:fix/pre-agg-refresh-key-cache-ttl
Open

fix(query-orchestrator): align pre-aggregation refresh key cache TTL with renewalThreshold#10993
igorferst wants to merge 1 commit into
cube-js:masterfrom
igorferst:fix/pre-agg-refresh-key-cache-ttl

Conversation

@igorferst
Copy link
Copy Markdown

@igorferst igorferst commented Jun 2, 2026

Summary

Pre-aggregation refresh key queries were cached with a hardcoded 1-hour Redis TTL in PreAggregationLoadCache.keyQueryResult, while refresh_key.every only controlled renewalThreshold. When every was longer than one hour (e.g. 15 days), the cache entry expired hourly, so refresh-key SQL still ran about every hour despite the model config.

This PR sets cache expiration to max(renewalThreshold, 1 hour) using the same resolved threshold as today (refresh_key.every, or queryCacheOptions.refreshKeyRenewalThreshold).

Why

  • renewalThreshold and Redis TTL were out of sync: stale logic could allow 15-day reuse in theory, but the key was removed after 1 hour → cache miss → refresh-key SQL re-executed.
  • Math.max(renewalThreshold, 60 * 60) fixes long every values and preserves the previous minimum 1-hour TTL for short thresholds (sql without every, default ~10s renewal, etc.).

Behavior changes

Config Before After
sql + every: '15 days' Refresh-key SQL ~hourly Cached ~15 days
sql only (renewalThreshold ~10s) 1h Redis TTL Still ≥1h Redis TTL
refreshKeyRenewalThreshold in orchestrator Overrides renewal only Overrides both renewal and expiration

Made with Cursor

…with renewalThreshold

Co-authored-by: Cursor <cursoragent@cursor.com>
@igorferst igorferst requested a review from a team as a code owner June 2, 2026 10:23
@github-actions github-actions Bot added javascript Pull requests that update Javascript code pr:community Contribution from Cube.js community members. labels Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code pr:community Contribution from Cube.js community members.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant