From e76b0b9b967496da0616d1727a47fb4d1084faea Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Wed, 5 Apr 2023 20:28:19 -0700 Subject: [PATCH] Move check for out of resources which would want a read lock out of inline processing Signed-off-by: Derek Collison --- server/raft.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/raft.go b/server/raft.go index b098ebe7..23500fbc 100644 --- a/server/raft.go +++ b/server/raft.go @@ -1758,9 +1758,15 @@ func (n *raft) setObserver(isObserver bool, extSt extensionState) { // Invoked when being notified that there is something in the entryc's queue func (n *raft) processAppendEntries() { + ok := !n.outOfResources() + if !ok { + n.debug("AppendEntry not processing inbound, no resources") + } aes := n.entry.pop() - for _, ae := range aes { - n.processAppendEntry(ae, ae.sub) + if ok { + for _, ae := range aes { + n.processAppendEntry(ae, ae.sub) + } } n.entry.recycle(&aes) } @@ -2697,11 +2703,6 @@ func (n *raft) runAsCandidate() { // handleAppendEntry handles an append entry from the wire. func (n *raft) handleAppendEntry(sub *subscription, c *client, _ *Account, subject, reply string, msg []byte) { - if n.outOfResources() { - n.debug("AppendEntry not processing inbound, no resources") - return - } - msg = copyBytes(msg) if ae, err := n.decodeAppendEntry(msg, sub, reply); err == nil { n.entry.push(ae)