#10726: fix: re-read session store inside lock in updateLastRoute
stale
Cluster:
Session Lock Improvements
## Summary
- `updateLastRoute` acquires the session store lock but reads the store without `skipCache`, which can return a stale cached copy and silently overwrite concurrent writes
- The sibling function `updateSessionStore` (line 272) already does this correctly: `loadSessionStore(storePath, { skipCache: true })` with the comment _"Always re-read inside the lock to avoid clobbering concurrent writers"_
- This fix applies the same established pattern to `updateLastRoute`
- Related to PR #10725 which fixes the same issue in `updateSessionStoreEntry`
## Test plan
- [x] All session store tests pass (7 tests)
- [x] Change matches the established pattern in `updateSessionStore`
Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Updates `updateLastRoute` to re-read the session store *inside* the file lock using `loadSessionStore(storePath, { skipCache: true })`.
- Aligns `updateLastRoute` with the existing concurrency-safe pattern already used in `updateSessionStore` to avoid clobbering concurrent writers due to cached reads.
- No other functional changes outside the session-store load behavior in `src/config/sessions/store.ts`.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Change is narrowly scoped and matches an established pattern in the same module to prevent stale cached reads under the session-store lock; no behavioral changes beyond improving concurrency correctness.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#10725: fix: re-read session store inside lock in updateSessionStoreEntry
by Yida-Dev · 2026-02-06
91.6%
#16987: fix(config): add skipCache to updateSessionStoreEntry and updateLas...
by AI-Reviewer-QS · 2026-02-15
90.8%
#16609: fix: resolve session store race condition and contextTokens updates
by battman21 · 2026-02-14
79.5%
#15882: fix: move session entry computation inside store lock to prevent ra...
by cloorus · 2026-02-14
78.3%
#4664: fix: per-session metadata files to eliminate lock contention
by tsukhani · 2026-01-30
76.7%
#20188: fix: Update sessionFile path when rolling to new session in cron jobs
by jriff · 2026-02-18
74.8%
#16542: fix(sessions): use atomic temp+rename write on Windows
by aldoeliacim · 2026-02-14
74.8%
#15628: fix: resolve session write lock race condition
by 1kuna · 2026-02-13
73.8%
#20770: fix: prevent stale session-entry overwrite during reset-model persi...
by coygeek · 2026-02-19
72.8%
#21828: fix: acquire session write lock in delivery mirror and gateway chat...
by inkolin · 2026-02-20
72.6%