Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXED] Hold JS lock when accessing stream assignment (#6173)
Fixes this data race: ``` WARNING: DATA RACE Read at 0x00c0034a4720 by goroutine 19950: runtime.mapiterinit() /home/travis/sdk/go1.23.3/src/runtime/map.go:877 +0x0 github.com/nats-io/nats-server/v2/server.TestJetStreamClusterMaxConsumersMultipleConcurrentRequests() /home/travis/build/nats-io/nats-server/server/jetstream_cluster_2_test.go:2080 +0xcc6 testing.tRunner() /home/travis/sdk/go1.23.3/src/testing/testing.go:1690 +0x226 testing.(*T).Run.gowrap1() /home/travis/sdk/go1.23.3/src/testing/testing.go:1743 +0x44 Previous write at 0x00c0034a4720 by goroutine 20101: runtime.mapassign_faststr() /home/travis/sdk/go1.23.3/src/runtime/map_faststr.go:223 +0x0 github.com/nats-io/nats-server/v2/server.(*jetStream).processConsumerAssignment() /home/travis/build/nats-io/nats-server/server/jetstream_cluster.go:4281 +0x834 github.com/nats-io/nats-server/v2/server.(*jetStream).applyMetaEntries() /home/travis/build/nats-io/nats-server/server/jetstream_cluster.go:2015 +0x78a github.com/nats-io/nats-server/v2/server.(*jetStream).monitorCluster() /home/travis/build/nats-io/nats-server/server/jetstream_cluster.go:1413 +0x1194 github.com/nats-io/nats-server/v2/server.(*jetStream).monitorCluster-fm() <autogenerated>:1 +0x33 github.com/nats-io/nats-server/v2/server.(*Server).startGoRoutine.func1() /home/travis/build/nats-io/nats-server/server/server.go:3885 +0x59 ``` `js.streamAssignment` mentions the lock should be held. Also found some other places that didn't lock. ```go // Will lookup a stream assignment. // Lock should be held. func (js *jetStream) streamAssignment(account, stream string) (sa *streamAssignment) { ``` Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
- Loading branch information