[GH-ISSUE #16011] server: stabilize TestSchedExpireRunner timeout #87882

Open
opened 2026-05-10 06:30:08 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @matteocelani on GitHub (May 6, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/16011

What is the issue?

The TestSchedExpireRunner test is frequently flaky in CI environments, especially on Windows and macOS runners. The test fails with the error message expected model to be unloaded, which indicates that a model remains in the scheduler's memory instead of being correctly expired and unloaded.

Technical Analysis

The issue is caused by a very aggressive context timeout of 20ms used in the test setup. In virtualized CI environments, the time needed to initialize the scheduler and process the asynchronous model unloading often exceeds this narrow window.

Logs from failed CI runs show the following debug message:
level=DEBUG msg="shutting down scheduler completed loop"

This confirms that the scheduler's background loop is exiting prematurely because the context has timed out. When the loop shuts down too early, it misses the signal to process the finished request and unload the model. As a result, the model stays in the internal "loaded" map, causing the test's final assertion to fail.

Example of failure:
https://github.com/ollama/ollama/actions/runs/25435750600/job/74613160524?pr=16001

Relevant log output

time=2026-05-06T12:51:27.651Z level=DEBUG msg="shutting down scheduler completed loop"
time=2026-05-06T12:51:27.651Z level=DEBUG msg="context for request finished"
--- FAIL: TestSchedExpireRunner (0.04s)
    sched_test.go:597: expected model to be unloaded

OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @matteocelani on GitHub (May 6, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/16011 ### What is the issue? The `TestSchedExpireRunner` test is frequently flaky in CI environments, especially on Windows and macOS runners. The test fails with the error message `expected model to be unloaded`, which indicates that a model remains in the scheduler's memory instead of being correctly expired and unloaded. ## Technical Analysis The issue is caused by a very aggressive context timeout of `20ms` used in the test setup. In virtualized CI environments, the time needed to initialize the scheduler and process the asynchronous model unloading often exceeds this narrow window. Logs from failed CI runs show the following debug message: `level=DEBUG msg="shutting down scheduler completed loop"` This confirms that the scheduler's background loop is exiting prematurely because the context has timed out. When the loop shuts down too early, it misses the signal to process the finished request and unload the model. As a result, the model stays in the internal "loaded" map, causing the test's final assertion to fail. Example of failure: https://github.com/ollama/ollama/actions/runs/25435750600/job/74613160524?pr=16001 ### Relevant log output ```shell time=2026-05-06T12:51:27.651Z level=DEBUG msg="shutting down scheduler completed loop" time=2026-05-06T12:51:27.651Z level=DEBUG msg="context for request finished" --- FAIL: TestSchedExpireRunner (0.04s) sched_test.go:597: expected model to be unloaded ``` ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2026-05-10 06:30:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#87882