Skip to content

Commit

Permalink
Merge pull request #3968 from nats-io/raft-warn-on-closed
Browse files Browse the repository at this point in the history
Don't warn if error is node closed.
  • Loading branch information
derekcollison committed Mar 16, 2023
2 parents 032b1f1 + 8dbfbbe commit d1048ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions server/jetstream_cluster_3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2958,6 +2958,7 @@ func TestJetStreamClusterWorkQueueConsumerReplicatedAfterScaleUp(t *testing.T) {

require_True(t, ci.Config.Replicas == 0 || ci.Config.Replicas == 3)

c.waitOnConsumerLeader(globalAccountName, "TEST", ci.Name)
s := c.consumerLeader(globalAccountName, "TEST", ci.Name)
require_NotNil(t, s)

Expand Down
8 changes: 6 additions & 2 deletions server/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -2507,6 +2507,10 @@ func (n *raft) applyCommit(index uint64) error {
// Used to track a success response and apply entries.
func (n *raft) trackResponse(ar *appendEntryResponse) {
n.Lock()
if n.state == Closed {
n.Unlock()
return
}

// Update peer's last index.
if ps := n.peers[ar.peer]; ps != nil && ar.index > ps.li {
Expand All @@ -2532,8 +2536,8 @@ func (n *raft) trackResponse(ar *appendEntryResponse) {
if nr := len(results); nr >= n.qn {
// We have a quorum.
for index := n.commit + 1; index <= ar.index; index++ {
if err := n.applyCommit(index); err != nil {
n.error("Got an error apply commit for %d: %v", index, err)
if err := n.applyCommit(index); err != nil && err != errNodeClosed {
n.error("Got an error applying commit for %d: %v", index, err)
break
}
}
Expand Down

0 comments on commit d1048ac

Please sign in to comment.