You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Orderly consumption per-queue lock is ineffective: QueueLock.fetchLock value receiver copies the sync.Map and returns a new mutex every call #1239
Every call copies the whole struct (flagged by go vet copylocks), so LoadOrStore writes into a discarded copy and the original map stays empty forever — each call returns a brand-new *sync.Mutex.
The only caller is consumeMessageOrderly (consumer/push_consumer.go): lock := pc.queueLock.fetchLock(*mq); lock.Lock(). Since every goroutine gets its own mutex, the per-queue mutual exclusion is completely ineffective: multiple goroutines can process the same MessageQueue concurrently, breaking the FIFO guarantee that orderly consumption exists to provide.
Steps to Reproduce
Two deterministic tests (included in the incoming PR):
Identity: call fetchLock twice for the same queue — unfixed returns two different mutexes.
Mutual exclusion: 20 goroutines fetch the lock for the same queue and record max concurrency — unfixed observes maxConcurrent=20 (zero serialization); fixed observes maxConcurrent=1.
go vet ./consumer/ also reports the copylocks diagnostic on this method.
What Did You Expect to See?
Same queue → same lock; orderly consumption strictly serialized per queue.
What Did You See Instead?
A fresh lock per call; per-queue ordering not enforced.
Additional Context
Fix incoming: change the receiver to *QueueLock (one character). go vet copylocks disappears; both tests flip from FAIL to PASS; the consumer suite passes with no regressions.
Activity