From ca3fe646b11b21acdf114df78dc39a1c5a784971 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 26 Oct 2018 14:45:16 +0200 Subject: [PATCH] Fix race condition when shutting down and watchPeers() run License: MIT Signed-off-by: Hector Sanjuan --- cluster.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cluster.go b/cluster.go index 834344da..7ca3bffa 100644 --- a/cluster.go +++ b/cluster.go @@ -313,6 +313,8 @@ func (c *Cluster) watchPeers() { } if !hasMe { + c.shutdownLock.Lock() + defer c.shutdownLock.Unlock() logger.Infof("%s: removed from raft. Initiating shutdown", c.id.Pretty()) c.removed = true go c.Shutdown()