Repository navigation
store: make valkey UpdateSessionLastActivity atomic - #511
altf4-games wants to merge 1 commit into
Conversation
Signed-off-by: Pradyum Mistry <39883432+altf4-games@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #511 +/- ##
==========================================
+ Coverage 60.45% 63.85% +3.40%
==========================================
Files 35 35
Lines 3616 3655 +39
==========================================
+ Hits 2186 2334 +148
+ Misses 1211 1090 -121
- Partials 219 231 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What type of PR is this?
/kind bug
What this PR does / why we need it:
valkeyStore.UpdateSessionLastActivitychecks the session key withEXISTSand then runsZADDon the last-activity index as a separate command. If the session gets deleted between the two (by GC, or a DELETE request callingDeleteSandboxBySessionID), theZADDputs the deleted session back into the index and the call still returns nil. The router calls this after every proxied request, so a session deleted while a request is in flight can hit it. The leftover member has no session key, which is the orphaned entry problem in #491.#358 fixed the same pattern in the redis store with a Lua script, and @hzxuzhonghu asked there for the valkey store to get the same change in a follow-up. This is that follow-up. It only affects
STORE_TYPE=valkey; redis is the default.Changes:
updateSessionLastActivityLuaconstant used by both stores, so they can't drift apart again.valkey.NewLuaScript(...).Exec. A missing session still returnsErrNotFound.TestValkeyStore_UpdateSessionLastActivity_ConcurrentDelete. A client wrapper runsDeleteSandboxBySessionIDright after the first round trip, once with the script not yet cached (EVAL fallback) and once cached (EVALSHA). It fails on main, where the deleted session ends up back in the index, and passes with this change.This stops new orphaned entries from being created this way. Cleaning up existing ones is #495.
Which issue(s) this PR fixes:
Refs #358, #491
Special notes for your reviewer:
I ran
go test -race ./pkg/store, thepkg/workloadmanagerandpkg/routertests, andmake lint.AI use: I used Claude to help find the bug and draft the fix and the test. I reviewed and ran all of it and can explain each line.
Does this PR introduce a user-facing change?: