Skip to content

fix(query-orchestrator): Return cached result when refreshKey changes during must-revalidate#10489

Merged
ovr merged 10 commits intomasterfrom
fix/must-revalidate-refresh-key-issue-simple-way
Mar 17, 2026
Merged

fix(query-orchestrator): Return cached result when refreshKey changes during must-revalidate#10489
ovr merged 10 commits intomasterfrom
fix/must-revalidate-refresh-key-issue-simple-way

Conversation

@ovr
Copy link
Member

@ovr ovr commented Mar 11, 2026

When refreshKey changes faster than the query executes (e.g. SELECT NOW() with a slow query), must-revalidate gets stuck in an endless Continue wait loop. Each time the query finishes, the refreshKey has already changed — so it re-runs the query, which never catches up.

Fix:

Track which request produced the cached result. If the same request flow already has a result in cache but the refreshKey changed during execution — return the cached data immediately and refresh in the background, instead of blocking and re-executing.

@github-actions github-actions bot added the javascript Pull requests that update Javascript code label Mar 11, 2026
@ovr ovr force-pushed the fix/must-revalidate-refresh-key-issue-simple-way branch from ec8c96a to 70f045d Compare March 16, 2026 13:17
@ovr ovr force-pushed the fix/must-revalidate-refresh-key-issue-simple-way branch from 70f045d to efe66f4 Compare March 16, 2026 13:19
@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.71%. Comparing base (018952a) to head (766bb84).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...-query-orchestrator/src/orchestrator/QueryCache.ts 72.72% 2 Missing and 1 partial ⚠️

❗ There is a different number of reports uploaded between BASE (018952a) and HEAD (766bb84). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (018952a) HEAD (766bb84)
cubesql 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #10489       +/-   ##
===========================================
- Coverage   83.39%   57.71%   -25.69%     
===========================================
  Files         250      223       -27     
  Lines       75112    17519    -57593     
  Branches        0     3604     +3604     
===========================================
- Hits        62642    10111    -52531     
+ Misses      12470     6866     -5604     
- Partials        0      542      +542     
Flag Coverage Δ
cube-backend 57.71% <76.92%> (?)
cubesql ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ovr ovr changed the title Fix/must revalidate refresh key issue simple way fix(query-orchestrator): Return cached result when refreshKey changes during must-revalidate Mar 16, 2026
@ovr ovr marked this pull request as ready for review March 16, 2026 16:18
@ovr ovr requested a review from a team as a code owner March 16, 2026 16:18
@ovr ovr merged commit e00fe12 into master Mar 17, 2026
72 of 74 checks passed
@ovr ovr deleted the fix/must-revalidate-refresh-key-issue-simple-way branch March 17, 2026 11:53
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants