Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix install stream snapshots on graceful shutdown (#5809)
Upon graceful shutdown, stream snapshots aren't installed: stream.go ```go } else { // Always attempt snapshot on clean exit. n.InstallSnapshot(mset.stateSnapshotLocked()) n.Stop() } ``` But raft.go exits immediately since it's in Closed state ```go if n.State() == Closed { return errNodeClosed } ``` This turns out to be because of calling either of `close(mset.mqch)` or `close(mset.qch)`. Which then calls the following upon leaving `monitorStream`: ```go // Make sure to stop the raft group on exit to prevent accidental memory bloat. // This should be below the checkInMonitor call though to avoid stopping it out // from underneath the one that is running since it will be the same raft node. defer n.Stop() ``` This PR proposes to skip running `n.Stop()` from `monitorStream` when we know we're closing / have called `mset.stop()`. Which will already take care of calling either `n.Stop()` or `n.Delete()` so there's no need in stopping from `monitorStream` in that case. TLDR; this ensures stream snapshots are installed upon shutdown. Signed-off-by: Maurice van Veen <[email protected]> --------- Signed-off-by: Maurice van Veen <[email protected]>
- Loading branch information