|
|
|
@ -36,10 +36,6 @@ var (
|
|
|
|
|
// operation.
|
|
|
|
|
ErrNotLeader = errors.New("not leader")
|
|
|
|
|
|
|
|
|
|
// ErrSelfJoin is returned when a join-request is received from a node
|
|
|
|
|
// with the same Raft ID as this node.
|
|
|
|
|
ErrSelfJoin = errors.New("self-join attempted")
|
|
|
|
|
|
|
|
|
|
// ErrStaleRead is returned if the executing the query would violate the
|
|
|
|
|
// requested freshness.
|
|
|
|
|
ErrStaleRead = errors.New("stale read")
|
|
|
|
@ -214,9 +210,10 @@ type Store struct {
|
|
|
|
|
numTrailingLogs uint64
|
|
|
|
|
|
|
|
|
|
// For whitebox testing
|
|
|
|
|
numNoops int
|
|
|
|
|
numSnapshotsMu sync.Mutex
|
|
|
|
|
numSnapshots int
|
|
|
|
|
numIgnoredJoins int
|
|
|
|
|
numNoops int
|
|
|
|
|
numSnapshotsMu sync.Mutex
|
|
|
|
|
numSnapshots int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsNewNode returns whether a node using raftDir would be a brand-new node.
|
|
|
|
@ -1013,9 +1010,6 @@ func (s *Store) Join(id, addr string, voter bool) error {
|
|
|
|
|
if s.raft.State() != raft.Leader {
|
|
|
|
|
return ErrNotLeader
|
|
|
|
|
}
|
|
|
|
|
if id == s.raftID {
|
|
|
|
|
return ErrSelfJoin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
configFuture := s.raft.GetConfiguration()
|
|
|
|
|
if err := configFuture.Error(); err != nil {
|
|
|
|
@ -1031,6 +1025,7 @@ func (s *Store) Join(id, addr string, voter bool) error {
|
|
|
|
|
// join is actually needed.
|
|
|
|
|
if srv.Address == raft.ServerAddress(addr) && srv.ID == raft.ServerID(id) {
|
|
|
|
|
stats.Add(numIgnoredJoins, 1)
|
|
|
|
|
s.numIgnoredJoins++
|
|
|
|
|
s.logger.Printf("node %s at %s already member of cluster, ignoring join request", id, addr)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|