Repository navigation
Conversation
… unload When --sleep-idle-seconds puts the server to sleep, a request that passed wait_until_no_sleep() but had not yet posted its task could be stranded: the main loop saw an empty queue, entered sleep, and unloaded the model while the handler was still tokenizing (observed as a hang and a SIGSEGV). Track in-flight requests with an n_inflight counter guarded by mutex_tasks. wait_until_no_sleep() claims a slot once the server is awake; the claim is released via RAII (server_res_generator) after the task is posted, and should_sleep() refuses to sleep while any claim is outstanding. Adds tests/test-server-queue.cpp: deterministic regression test that fails without the should_sleep() guard and passes with it. Fixes ggml-org#29689
|
Hi @vyalamar, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
Human here . I will share the handwritten architecture diagram to explain these changed. I had it somewhere let me find and share. Also I am trying to test this on Mac and windows platforms and reproduce the behavior ( it's platform agonistic though) . I will share the logs with before and after to prove the fix works . Please allow sometime. |
|
Superseded by #32133. |
Fixes #29689.
The bug
With
--sleep-idle-seconds, a request can arrive in the exact window where the server is falling asleep:wait_until_no_sleep()and observes the server awake.req_stop_sleeping, not queued work.Results: the task is stranded while the client hangs, and on Linux the model unload racing tokenization produced a SIGSEGV.
The fix
server_queuegains ann_inflightcounter guarded bymutex_tasks.wait_until_no_sleep()claims a slot once the server is confirmed awake.server_res_generator) after the task is posted, so early validation/error returns cannot leak it.should_sleep()refuses to sleep whilen_inflight > 0.Testing
tests/test-server-queue.cpp: a deterministic regression test that drives the queue directly — it fails withBUG #29689: server fell asleep while a request was in-flightwhen theshould_sleep()guard is removed, and passes with the fix.llama-server(CPU) and the new test target;git diff --checkclean.