You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make workload activation and deletion state transitions concurrency-safe #445
Workload activation, status refresh, and deletion use read-modify-write updates in Redis without compare-and-set protection. Concurrent requests can overwrite a newer state. For example, an activation or GET refresh can restore a record after deletion and leave Sandbox or Context resources orphaned.
Concurrent creation is already tracked by #356. The GET write-back race is also noted in #363. This issue covers the remaining workload lifecycle as one state-machine problem.
Scope
Add versioned or compare-and-set workload record updates.
Define allowed state transitions.
Prevent GET refresh from overwriting deleting or deleted.
Prevent activation from creating or recording Sandboxes after deletion begins.
Make cleanup and retry behavior idempotent.
Add deterministic concurrent activation/delete and GET/delete tests.
Acceptance criteria
A deleted workload cannot return to an active state.
Concurrent activation and deletion leave no orphaned Sandboxes or Context storage.
Retried operations converge on one valid terminal state.
Tests cover the races without timing-dependent sleeps.
Idempotent cleanup and retry — a delete Context Service failed midway stays deleting and a repeated DELETE retries it; deleteContext treats 404 as deleted; test: pin the GET/delete and double-delete workload lifecycle races (#445) #549 pins that two concurrent DELETEs converge on one deleted record, one Context deletion and one quota release.
Deterministic tests, no timing-dependent sleeps — the whole lifecycle races block, including the two new pins, drives the races through the test Context Service's hold() seam.
Known remainder, deliberately left as documented behavior: a create whose process dies between the reservation and the rollback leaves a creating record holding the name and one quota unit until the owner's DELETE clears it. A record TTL would not fix this safely — expiry skips the deleted transition that releases the quota unit, so it would leak permanently.
Activity
pdettori commentedon Oct 17, 2026
Closing record, mapped to the issue's scope (pinned in #549):
TRANSITIONLua script, a CAS on(generation, status);RESERVEmakes the name-and-quota reservation one atomic Redis op (also what closed POST /workloads: concurrent create of one new name can hand the owner to the later writer #356).creating → awaiting_upload → ready → deleting → deleted, no others; enumerated indocs/context-service.md.deletingordeleted— GET has been read-only since the phase-1 rewrite; test: pin the GET/delete and double-delete workload lifecycle races (#445) #549 pins that a GET inside the delete window leaves the stored record byte-identical (this was MI1 S1 follow-up: #350 round-3 review items (SH_MODEL_HEADERS, Vertex ADC, GET write-back race, pins, doc fixes) #363's "GET write-back race" bullet).404.deletingand a repeatedDELETEretries it;deleteContexttreats 404 as deleted; test: pin the GET/delete and double-delete workload lifecycle races (#445) #549 pins that two concurrentDELETEs converge on onedeletedrecord, one Context deletion and one quota release.lifecycle racesblock, including the two new pins, drives the races through the test Context Service'shold()seam.Known remainder, deliberately left as documented behavior: a create whose process dies between the reservation and the rollback leaves a
creatingrecord holding the name and one quota unit until the owner'sDELETEclears it. A record TTL would not fix this safely — expiry skips thedeletedtransition that releases the quota unit, so it would leak permanently.test: pin the GET/delete and double-delete lifecycle races #445 close…
Merge pull request #549 from pdettori/fix/445-workload-races