diff --git a/modules/queue/workerpool.go b/modules/queue/workerpool.go index 37d518aa86..5f52fef588 100644 --- a/modules/queue/workerpool.go +++ b/modules/queue/workerpool.go @@ -19,6 +19,10 @@ import ( // they use to detect if there is a block and will grow and shrink in // response to demand as per configuration. type WorkerPool struct { + // This field requires to be the first one in the struct. + // This is to allow 64 bit atomic operations on 32-bit machines. + // See: https://pkg.go.dev/sync/atomic#pkg-note-BUG & Gitea issue 19518 + numInQueue int64 lock sync.Mutex baseCtx context.Context baseCtxCancel context.CancelFunc @@ -32,7 +36,6 @@ type WorkerPool struct { blockTimeout time.Duration boostTimeout time.Duration boostWorkers int - numInQueue int64 } // WorkerPoolConfiguration is the basic configuration for a WorkerPool