Move check for out of resources which would want a read lock out of inline processing

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2023-04-05 20:28:19 -07:00
parent b6ebf0fe43
commit e76b0b9b96

View File

@@ -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)