From 35ccabac2889582ae7a5613874972bb3365930ab Mon Sep 17 00:00:00 2001 From: Ilker Manap Date: Fri, 16 Oct 2026 22:40:09 +0200 Subject: [PATCH] modelserve: a job's request is set under the lock Get reads it with CI run 394, on a commit that changed only BACKLOG.md, failed with a data race in TestAVisionModelIsServedWithItsProjectorBesideIt. The serve job's goroutine wrote j.Request without the lock (since efffdb6, which sized embedding slots), while Get's snapshot read the job under it. Every other write to a running job holds the lock. It did not reproduce in 30 runs here; the race detector's trace names this write and that read. Co-Authored-By: Claude Opus 5.5 (1M context) --- internal/control/modelserve/modelserve.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/control/modelserve/modelserve.go b/internal/control/modelserve/modelserve.go index d29dbf45..fc04af4d 100644 --- a/internal/control/modelserve/modelserve.go +++ b/internal/control/modelserve/modelserve.go @@ -504,7 +504,11 @@ func (s *Server) run(j *Job) { req = fitted } } + // Under the lock: a job is read by Get while it runs, and the race + // detector caught this write beside it. + s.mu.Lock() j.Request = req + s.mu.Unlock() memGB := int((header.MemoryBytes(set.Bytes, req.CtxPool) + 1<<30 - 1) >> 30) basis := fmt.Sprintf("weights %.1f GB + KV cache %.1f GB for %d tokens + engine", gb(set.Bytes), gb(int64(req.CtxPool)*header.KVBytesPerToken()), req.CtxPool)