From 782aeba89972b2d2cf1f98dd0f93111495c61f54 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Tue, 16 Jan 2024 12:57:04 -0800 Subject: [PATCH] Fix for a datarace with stream stop and removal from jsa.streams. Signed-off-by: Derek Collison --- server/jetstream_cluster.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/jetstream_cluster.go b/server/jetstream_cluster.go index 770b9957e73..080d3dd916c 100644 --- a/server/jetstream_cluster.go +++ b/server/jetstream_cluster.go @@ -1123,6 +1123,7 @@ func (js *jetStream) checkForOrphans() { for accName, jsa := range js.accounts { asa := cc.streams[accName] + jsa.mu.RLock() for stream, mset := range jsa.streams { if sa := asa[stream]; sa == nil { streams = append(streams, mset) @@ -1136,6 +1137,7 @@ func (js *jetStream) checkForOrphans() { } } } + jsa.mu.RUnlock() } js.mu.Unlock()