Repository navigation
Conversation
CachingStateSync.get_snapshots computed expire_at before calling the underlying state sync. When that fetch took longer than the TTL, the entries it returned were stored already expired and the next lookup fetched them again. Fixes SQLMesh#6209 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hq1ACTsK85bRrY28fUQ7b3 Signed-off-by: Eliot5566 <a7868783@gmail.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Description
Fixes #6209.
CachingStateSync.get_snapshots()computedexpire_atbefore calling the underlying state sync. When that call took longer than the TTL, the snapshots it returned went into the cache already expired, so the next lookup fetched them again.expire_atis now recomputed once the fetch returns and used for everything that fetch resolved, including theFalseplaceholders for snapshots that do not exist. Cache hits keep the deadline they already had. The placeholders are still written before the fetch, so behaviour after a failed backend read is unchanged.One thing for reviewers to decide: the issue asks whether expiry relative to fetch start was intentional. I assumed it was not, since it makes a slow cold load uncacheable.
Test Plan
Added
test_cache_ttl_starts_after_slow_fetch. It uses a fake state sync that advances the clock by 11 s during the fetch withttl=10, then checks that an immediate second lookup does not hit the backend and that a lookup after the TTL does. It fails onmain(2 backend reads instead of 1).tests/core/state_sync/test_state_sync.pyandtests/core/test_context.pygive the same results before and after the change in my environment, apart from the new test. 48 tests in those files fail or error for me onmainas well becauseexamples/custom_materializationsis not installed locally, so I am relying on CI for the full suite.Checklist
make styleand fixed any issuesmake fast-test)git commit -s) per the DCOI ran ruff, ruff format and mypy on the changed files only, so the first box is unticked. I used Claude to help write and test this change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Hq1ACTsK85bRrY28fUQ7b3
Summary by CodeRabbit