From 2a09bd47baa3120a08b64f32512c3d11bfea0cad Mon Sep 17 00:00:00 2001 From: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:52:40 -0400 Subject: [PATCH] raft/autopilot: fix panic during autopilot shutdown (#27726) * raft/autopilot: fix panic during autopilot shutdown * changelog --- changelog/27726.txt | 3 +++ physical/raft/raft_autopilot.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog/27726.txt diff --git a/changelog/27726.txt b/changelog/27726.txt new file mode 100644 index 0000000000..80f2cc850f --- /dev/null +++ b/changelog/27726.txt @@ -0,0 +1,3 @@ +```release-note:bug +raft/autopilot: Fixed panic that may occur during shutdown +``` diff --git a/physical/raft/raft_autopilot.go b/physical/raft/raft_autopilot.go index d6f8889809..6a5edf9703 100644 --- a/physical/raft/raft_autopilot.go +++ b/physical/raft/raft_autopilot.go @@ -636,7 +636,8 @@ func (b *RaftBackend) StopAutopilot() { if b.autopilot == nil { return } - b.autopilot.Stop() + stopCh := b.autopilot.Stop() + <-stopCh b.autopilot = nil b.followerHeartbeatTicker.Stop() }