• Stefy Lanza (nextime / spora )'s avatar
    a cancelled page kept the pod slot it was granted (v0.4.23) · 1ccc44f8
    Stefy Lanza (nextime / spora ) authored
    `placement.choose` runs in a thread and raises `pod.inflight` the moment it
    picks a pod. If the awaiting coroutine was cancelled after the executor had
    produced the Lease but before the value was delivered, the object was dropped
    with the counter already raised -- and nothing released it, because the page
    was gone and no `finally` ran.
    
    A client that gives up on a batch cancels every page of it at once, so the leak
    arrives in thousands rather than one at a time.
    
    Measured on a live run, once `max_inflight_per_pod: 64` made it visible: the
    pool reported all 52 healthy pods at their cap -- 3,328 pages "in flight" --
    while `ss` inside the container showed 3 to 5 open sockets per pod, the cards
    sat at `GPU KV cache usage: 0.2%` with `Running: 1 reqs`, and nothing was
    preempted. Roughly 60 of every 64 pages did not exist. `_pick` then refused
    every pod, correctly, reporting "all 52 serving pod(s) are at their in-flight
    cap", and the run fell to 0.33 pages/s.
    
    It had been leaking since the pod pipeline was written. With
    `max_inflight_per_pod: 0` an inflated counter blocks nothing, so the only
    symptom was DEMAND -- the in-flight counts of 2,700 and 4,096 that earlier runs
    reported, and that the scaler dutifully rented pods to serve. The cap did not
    cause this; it converted a silent accounting error into a hard stop, which is
    how it was finally found. Three runs were spent on its consequences.
    
    `_acquire_lease` shields the acquisition, so it completes even when the page
    waiting on it is cancelled, and a done-callback hands the lease straight back.
    Orphans are counted and said once a minute, because the entire cost of this bug
    was that it was silent.
    
    Note on the analysis: the gap between `lease = await ...` and the `try` that
    releases it is NOT a window -- CancelledError is only delivered at an await
    point, and there is none in between. The acquisition itself was the only one.
    
    Proven rather than argued: the same test, same cancellation, against the
    unshielded form and the shielded one -- granted=1 released=0 LEAKED=1, against
    granted=1 released=1 LEAKED=0.
    Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01KnfkxBpcZ1v6ypRFFyhrVM
    1ccc44f8
Name
Last commit
Last update
..
schemas_builtin Loading commit data...
workers Loading commit data...
__init__.py Loading commit data...
base.py Loading commit data...
budget.py Loading commit data...
chandra.py Loading commit data...
detect.py Loading commit data...
doctr.py Loading commit data...
extract.py Loading commit data...
gateway.py Loading commit data...
manager.py Loading commit data...
olmocr.py Loading commit data...
paddle.py Loading commit data...
rasterize.py Loading commit data...
resume.py Loading commit data...
schemas.py Loading commit data...
served_model.py Loading commit data...
subprocess_engine.py Loading commit data...
surya.py Loading commit data...
venv_build.py Loading commit data...