diff --git a/.changelog/12496.txt b/.changelog/12496.txt new file mode 100644 index 0000000000..ad268bc67f --- /dev/null +++ b/.changelog/12496.txt @@ -0,0 +1,3 @@ +```release-note:bug +raft: upgrade to v1.3.6 which fixes a bug where a read replica node could attempt bootstrapping raft and prevent other nodes from bootstrapping at all +``` diff --git a/agent/consul/server.go b/agent/consul/server.go index dd3df88101..b9ad053ee4 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -822,7 +822,7 @@ func (s *Server) setupRaft() error { // If we are in bootstrap or dev mode and the state is clean then we can // bootstrap now. - if s.config.Bootstrap || s.config.DevMode { + if (s.config.Bootstrap || s.config.DevMode) && !s.config.ReadReplica { hasState, err := raft.HasExistingState(log, stable, snap) if err != nil { return err diff --git a/agent/consul/server_serf.go b/agent/consul/server_serf.go index ff1b1e4064..56af75fef2 100644 --- a/agent/consul/server_serf.go +++ b/agent/consul/server_serf.go @@ -386,6 +386,11 @@ func (s *Server) maybeBootstrap() { return } + if s.config.ReadReplica { + s.logger.Info("Read replicas cannot bootstrap raft") + return + } + // Scan for all the known servers. members := s.serfLAN.Members() var servers []metadata.Server diff --git a/go.mod b/go.mod index e0d8bf77ab..cf8a79ff5f 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/hil v0.0.0-20200423225030-a18a1cd20038 github.com/hashicorp/memberlist v0.3.1 - github.com/hashicorp/raft v1.3.5 + github.com/hashicorp/raft v1.3.6 github.com/hashicorp/raft-autopilot v0.1.5 github.com/hashicorp/raft-boltdb v0.0.0-20211202195631-7d34b9fb3f42 // indirect github.com/hashicorp/raft-boltdb/v2 v2.2.0 diff --git a/go.sum b/go.sum index 2617fbb0d5..a027680b2d 100644 --- a/go.sum +++ b/go.sum @@ -295,8 +295,8 @@ github.com/hashicorp/memberlist v0.3.1/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn github.com/hashicorp/raft v1.1.0/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM= github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= github.com/hashicorp/raft v1.2.0/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft v1.3.5 h1:93YBXmHWW2MuyMZfMxN1PsAnPXAt+hBfG0S0ZrZxRrY= -github.com/hashicorp/raft v1.3.5/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM= +github.com/hashicorp/raft v1.3.6 h1:v5xW5KzByoerQlN/o31VJrFNiozgzGyDoMgDJgXpsto= +github.com/hashicorp/raft v1.3.6/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM= github.com/hashicorp/raft-autopilot v0.1.5 h1:onEfMH5uHVdXQqtas36zXUHEZxLdsJVu/nXHLcLdL1I= github.com/hashicorp/raft-autopilot v0.1.5/go.mod h1:Af4jZBwaNOI+tXfIqIdbcAnh/UyyqIMj/pOISIfhArw= github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk=