Conversation
|
| Filename | Overview |
|---|---|
| api/models.py | Refactors CLI session cache rebuilds around shared in-flight, invalidation, and cache-store helpers. |
| tests/test_issue4842_cli_cache_streaming.py | Adds concurrency tests for stale reuse, follower fallback, cache clears during rebuilds, and stale-store rejection. |
Reviews (6): Last reviewed commit: "fix(cli): restore all-profiles session s..." | Re-trigger Greptile
|
Strong work — the singleflight + stale-while-revalidate shape is right, and the dual gate confirmed the core concurrency is sound: owner-exception wakeup (try/finally always reaches 🔴 MUST-FIX 1 — follower can return
|
|
I tightened the follower side of
|
|
Shipped in v0.51.671 (Release YA, just deployed) — thanks @rodboev! Closes #4842. The CLI/cron sidebar rebuild now runs outside the cache lock (stale-while-revalidate + singleflight), so a cron-heavy rebuild no longer serializes every /api/sessions poll. Both bounce items resolved: Codex reproduced the prior clear-during-rebuild race and confirmed the follower now re-claims + returns fresh rows (not []); all waits bounded. Gate: Codex SAFE + Opus SHIP IT, suite 10653. Completes the #4842 chain on top of #4889 + #4908/#4949. Verified on prod. |
…k (SWR+singleflight) (nesquena#4952, closes nesquena#4842)
Thinking Path
api/models.py.get_cli_sessions()stall was in the follower path after invalidation: a cold follower could wait forever, and a clear during rebuild could leave a joiner with no valid cache entry and fall through to[].What Changed
api/models.py: split the rebuild path into shared helpers, cap cold followers at a 0.25s wait before an independent rebuild, make invalidated joiners loop back and reclaim rebuild ownership after the old inflight slot drops, reuse fresh cache entries when available, remove the dead post-return fallback block, repair the warning log string, and keep the all-profiles branch on the shared cache path.tests/test_issue4842_cli_cache_streaming.py: add focused regressions for the cold-follower timeout fallback and the clear-during-rebuild joiner that used to return[], alongside the existing streaming and invalidation coverage.Why It Matters
This keeps
/api/sessionsresponsive on slow or wedged rebuilds, it closes the silent empty-sidebar case afterclear_cli_sessions_cache(), and it preserves the all-profiles scan behavior that pulls named-profile CLI sessions into the aggregate view. Sidebar rows stay consistent, but followers no longer hang indefinitely or drop CLI and cron sessions.Verification
pytest tests/test_issue4842_cli_cache_streaming.py tests/test_cli_sessions_cache_fingerprint.py -v --timeout=6011 passed, 1 warning in 6.30sFull-suite CI context, not a required local check unless requested:
pytest tests/ -v --timeout=60.Upstream
Closes #4842.
Attribution: the reporter's one-session traces and lock diagnosis on #4842 narrowed this fix to the CLI cache rebuild path after the earlier shipped slices in #4889 and #4949.
Model Used
GPT 5.5 via Codex CLI