Skip to content

Commit

Permalink
Speculative fix for a panic that might arise during raft teardown (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
ncabatoff authored and AnPucel committed Feb 3, 2023
1 parent ac9da60 commit 2ae342b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog/18704.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
storage/raft: Fix race with follower heartbeat tracker during teardown.
```
7 changes: 7 additions & 0 deletions physical/raft/raft_autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,13 @@ func (b *RaftBackend) startFollowerHeartbeatTracker() {
}
for range tickerCh {
b.l.RLock()
if b.raft == nil {
// We could be racing with teardown, which will stop the ticker
// but that doesn't guarantee that we won't reach this line with a nil
// b.raft.
b.l.RUnlock()
return
}
b.followerStates.l.RLock()
myAppliedIndex := b.raft.AppliedIndex()
for peerID, state := range b.followerStates.followers {
Expand Down

0 comments on commit 2ae342b

Please sign in to comment.