[PR #15622] fix: flaky TestSchedExpireRunner on Windows CI #20459

Open
opened 2026-04-16 07:38:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15622
Author: @CrispStrobe
Created: 4/16/2026
Status: 🔄 Open

Base: main ← Head: fix/flaky-sched-expire-runner-test


📝 Commits (1)

  • 610517b fix: flaky TestSchedExpireRunner on Windows CI

📊 Changes

1 file changed (+29 additions, -6 deletions)

View changed files

📝 server/sched_test.go (+29 -6)

📄 Description

Summary

TestSchedExpireRunner fails intermittently on Windows CI (sched_test.go:597: expected model to be unloaded).

Root cause: The test uses a single 20ms context for both model loading and processCompleted(). Since processCompleted is a blocking for/select loop that only returns when its context expires, it must process two sequential channel events (finishedReqCh → expiredCh) within that 20ms window. On slow Windows CI runners, ctx.Done() wins the select race before the expiredCh case runs, so the runner never unloads.

Fix:

  • Run processCompleted in a goroutine with its own 500ms context
  • Poll for the unload condition (typically completes in <10ms) instead of checking synchronously after processCompleted returns
  • The test still fails fast on actual bugs — it just no longer races against its own timeout

Test plan

  • Verified the fix addresses the exact failure seen in CI run 24492718639
  • No changes to production code — test-only fix
  • Same assertion (expected model to be unloaded) preserved

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15622 **Author:** [@CrispStrobe](https://github.com/CrispStrobe) **Created:** 4/16/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/flaky-sched-expire-runner-test` --- ### 📝 Commits (1) - [`610517b`](https://github.com/ollama/ollama/commit/610517bc5252df90f137a01f09b581a680e6b2da) fix: flaky TestSchedExpireRunner on Windows CI ### 📊 Changes **1 file changed** (+29 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `server/sched_test.go` (+29 -6) </details> ### 📄 Description ## Summary `TestSchedExpireRunner` fails intermittently on Windows CI (`sched_test.go:597: expected model to be unloaded`). **Root cause:** The test uses a single 20ms context for both model loading and `processCompleted()`. Since `processCompleted` is a blocking `for/select` loop that only returns when its context expires, it must process two sequential channel events (`finishedReqCh` → `expiredCh`) within that 20ms window. On slow Windows CI runners, `ctx.Done()` wins the `select` race before the `expiredCh` case runs, so the runner never unloads. **Fix:** - Run `processCompleted` in a goroutine with its own 500ms context - Poll for the unload condition (typically completes in <10ms) instead of checking synchronously after `processCompleted` returns - The test still fails fast on actual bugs — it just no longer races against its own timeout ## Test plan - [x] Verified the fix addresses the exact failure seen in [CI run 24492718639](https://github.com/ollama/ollama/actions/runs/24492718639/job/71580821127) - [x] No changes to production code — test-only fix - [x] Same assertion (`expected model to be unloaded`) preserved 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 07:38:35 -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#20459