wang-jiahua opened a new pull request, #1240: URL: https://github.com/apache/rocketmq-client-go/pull/1240
### Which Issue(s) This PR Fixes Fixes #1239 ### Brief Description `QueueLock.fetchLock` used a value receiver on a struct containing a `sync.Map`. Every call copied the struct, `LoadOrStore` wrote into the discarded copy, and each caller got a brand-new mutex — so the per-queue lock taken by `consumeMessageOrderly` never actually excluded anyone, breaking the FIFO guarantee of orderly consumption. `go vet` flags this as copylocks. The fix is one character: value receiver → pointer receiver, so all callers share the same `lockTable` and the same per-queue mutex. ### How Did You Test This Change? Two new deterministic tests in `consumer/lock_test.go`, both red on the unfixed code and green with the fix: - `TestFetchLockReturnsSameLockForSameQueue`: unfixed returns two different mutexes for the same queue; fixed returns the identical one. - `TestFetchLockProvidesMutualExclusion`: 20 goroutines contend on one queue while recording max concurrency — unfixed observes `maxConcurrent=20` (no serialization at all); fixed observes `maxConcurrent=1`. `go vet ./consumer/` copylocks diagnostic: present before, gone after. `gofmt` clean; the consumer test suite passes with no regressions. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
