From 1ccc6dbf30ab7bb300a3f11b70753dd606b99d8a Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Tue, 3 Oct 2023 15:01:34 -0700 Subject: [PATCH 1/2] Bumped inflight updates to 16 and move one lock to rlock. Signed-off-by: Derek Collison --- server/jetstream_cluster.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/jetstream_cluster.go b/server/jetstream_cluster.go index 92e70501d8..964476aae2 100644 --- a/server/jetstream_cluster.go +++ b/server/jetstream_cluster.go @@ -7722,8 +7722,8 @@ func (mset *stream) isCurrent() bool { return mset.node.Current() && !mset.catchup } -// Maximum requests for the whole server that can be in flight. -const maxConcurrentSyncRequests = 8 +// Maximum requests for the whole server that can be in flight at the same time. +const maxConcurrentSyncRequests = 16 var ( errCatchupCorruptSnapshot = errors.New("corrupt stream snapshot detected") @@ -7900,11 +7900,11 @@ RETRY: // Grab sync request again on failures. if sreq == nil { - mset.mu.Lock() + mset.mu.RLock() var state StreamState mset.store.FastState(&state) sreq = mset.calculateSyncRequest(&state, snap) - mset.mu.Unlock() + mset.mu.RUnlock() if sreq == nil { return nil } From 2d21bc7008f9a2544d0d92a15cac601fb2bf340c Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Tue, 3 Oct 2023 15:35:20 -0700 Subject: [PATCH 2/2] Fix datarace Signed-off-by: Derek Collison --- server/raft.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/raft.go b/server/raft.go index 5bcc2a1a19..7baa949dfc 100644 --- a/server/raft.go +++ b/server/raft.go @@ -654,9 +654,9 @@ func (s *Server) transferRaftLeaders() bool { // This should only be called on the leader. func (n *raft) Propose(data []byte) error { n.RLock() - if n.state != Leader { + if state := n.state; state != Leader { n.RUnlock() - n.debug("Proposal ignored, not leader (state: %v)", n.state) + n.debug("Proposal ignored, not leader (state: %v)", state) return errNotLeader } // Error if we had a previous write error.