Repository navigation
fix(v2): cancel active drains and fence session deletes - #41
Conversation
Keep registered drains cancellable through claim release and terminal publication, and fence session deletion against new work. Bound drains, reservation waiters, prompt-lock waiters, and delete fences. Closes K-V2-DRAIN-CANCEL and K-SESSION-DELETE-FENCE (V2-PLAN P3). Focused v2 admission (22), drain and delete races (15), coordinator (5), fmt, clippy, guards, and matrix passed. Full workspace tests have macOS host failures in Linux cgroup and /proc assumptions; the ocserve-http suite also has an unrelated symlink-containment failure on this host.
Amendment to the contributor's branch (credited @jrzmurray), from the review. Three members of one class (blocking work on an executor that must stay free), plus two waits with no ceiling: * check_v1_session_admission ran session_exists (open_reader + SELECT) inline on EVERY v1 prompt — /message, /prompt_async, /command, /summarize, and the v2 create. It had also REPLACED the run_blocking call prompt_async already had, so the change was a net loss of offload. It is now async and goes through run_blocking. (F1 class, PERF-10X.) * lock_session_wait branched on the error MESSAGE string ("too many concurrent prompts") to detect capacity. A wording change would silently fall into the 1 Hz retry branch while holding a drain slot. Now matched on status + name. * scheduler::step awaited reserve_drain_slot_wait inside the single serial tick loop, so one slow drain stalled every other schedule. It now uses the non-blocking reservation and returns without marking the row, so the next pass retries. * cancel_drain bounded its watch wait; cancel_drains_for_delete bounded the WHOLE teardown. The first attempt bounded only the inner loop, and the outer re-cancel loop still spun forever — the regression test caught it. Both record ocserve_v2_drain_cancel_timeout_total. * the interrupt re-arm read session_exists(...).unwrap_or(false), so a read error was treated as "session gone" and silently dropped the work. It propagates. Docs: MEMORY states the drain cap is a COUNT bound and gives the real worst case (min(128 slots, 64 prompt locks) x history); PLAN gains D-V2-INTERRUPT-STATUS (one handler cannot return v1 204 and v2 200); TESTING and TRACEABILITY gain the class and its negative control. Verified: 929 workspace tests, clippy -D under CARGO_BUILD_WARNINGS=deny, guards, matrix, docs. Negative control for the delete bound: delete the outer deadline and the request hangs to the 90 s test timeout.
|
Thanks — the core insight is right and the delete fence is the correct shape. I approved the workflows (fork runs had never executed) and pushed two commits onto your branch; tell me if you would rather have them as a separate PR. What I changed, and the evidence
On the MEMORY claim: I rewrote it as an explicit count bound with the real worst case, One contract note, recorded not fixed: The 1,400-line inline test module stays: integration tests cannot see the |
The new knob was read in code but absent from the env contract, so the guard that exists to catch exactly this failed CI rather than the build passing with an undocumented knob. Group is 'Cgroups and lifecycle' (drain teardown), default 30 s, 0 = the old unbounded wait. docs/ENVIRONMENT.md regenerated. Already covered by K-OFFLOAD-ADMISSION in TRACEABILITY.md; this is the documentation half of the same change.
…ot a latency delta The point lookup measures 2.1 us, so no p50 improvement is claimed; the evidence is behavioural (the delete regression test). Recording this stops a future reader from inferring a perf win that was never measured.
Kept both sides in CHANGELOG, PLAN section 18 and TESTING 1.6: the permission rows from Reliary#40 and the drain/delete rows from this branch are independent.
The Reliary#41 branch made check_v1_session_admission async; main's Reliary#42 branch added a call site that was written against the sync signature. Caught by check-matrix (workspace must build before the test-existence check runs), which is exactly what that fail-closed behaviour is for.
What this changes
V2 interrupt now cancels the registered provider drain, reports its actual interruption result, and keeps later work ordered behind terminal publication. The bounded drain admission and per-session deletion fence prevent queued work or an in-flight turn from being stranded or writing into a deleted session. This change covers K-V2-DRAIN-CANCEL and K-SESSION-DELETE-FENCE.
Issue
Closes #
Verification
Linux CI remains the full-workspace gate.