[PR #14711] server: fix ticker leak in download chunk stall monitor #25343

Open
opened 2026-04-19 18:09:42 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14711
Author: @alvinttang
Created: 3/8/2026
Status: 🔄 Open

Base: mainHead: fix/download-ticker-leak


📝 Commits (1)

  • ab0c930 server: fix ticker leak in download chunk stall monitor

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 server/download.go (+1 -0)

📄 Description

What

Add missing defer ticker.Stop() in downloadChunk's stall-detection goroutine.

Why

In blobDownload.downloadChunk(), a time.NewTicker(time.Second) is created at line 362 but never stopped. This goroutine runs for every download chunk part, and when it exits (via return on completion, stall, or context cancellation), the ticker continues to fire, leaking its internal goroutine and channel.

During large model downloads with many parts, this can accumulate a significant number of leaked tickers.

Change

Add defer ticker.Stop() immediately after creating the ticker, consistent with how tickers are handled elsewhere in the codebase (e.g., sched.go:803, cmd.go:388).


🔄 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/14711 **Author:** [@alvinttang](https://github.com/alvinttang) **Created:** 3/8/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/download-ticker-leak` --- ### 📝 Commits (1) - [`ab0c930`](https://github.com/ollama/ollama/commit/ab0c9305853ef3eb82a7075a30c2dd86ff79af1b) server: fix ticker leak in download chunk stall monitor ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `server/download.go` (+1 -0) </details> ### 📄 Description ## What Add missing `defer ticker.Stop()` in `downloadChunk`'s stall-detection goroutine. ## Why In `blobDownload.downloadChunk()`, a `time.NewTicker(time.Second)` is created at line 362 but never stopped. This goroutine runs for every download chunk part, and when it exits (via `return` on completion, stall, or context cancellation), the ticker continues to fire, leaking its internal goroutine and channel. During large model downloads with many parts, this can accumulate a significant number of leaked tickers. ## Change Add `defer ticker.Stop()` immediately after creating the ticker, consistent with how tickers are handled elsewhere in the codebase (e.g., `sched.go:803`, `cmd.go:388`). --- <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-19 18:09:42 -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#25343