Skip to content

Commit

Permalink
etcdserver: intentionally set memberID as 0 when can't identify the c…
Browse files Browse the repository at this point in the history
…orrupted member

If quorum doesn't exist, we don't know which members data are
corrupted. In such situation, we intentionally set the memberID
as 0, it means it affects the whole cluster.
It's align with what we did for 3.4 and 3.5 in
etcd-io#14849

Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Nov 25, 2022
1 parent 79ff3f8 commit 04775da
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions server/etcdserver/corrupt.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/json"
"fmt"
"io"
"math"
"net/http"
"sort"
"strings"
Expand Down Expand Up @@ -343,36 +342,16 @@ func (cm *corruptionChecker) checkPeerHashes(leaderHash mvcc.KeyValueHash, peers
}

if !quorumExist {
// If quorumExist doesn't exist, then only raise alarm for the least minority.
// The first step is to find out the members which are the least minority.
var (
minCnt int = math.MaxInt
hashVal uint32
memberIDs types.IDSlice
)

for k, v := range hash2members {
if v.Len() < minCnt {
minCnt = v.Len()
hashVal = k
memberIDs = v
}
}

// raise alarms
for _, pid := range memberIDs {
cm.hasher.TriggerCorruptAlarm(pid)
}
delete(hash2members, hashVal)

cm.lg.Error("Detected compaction hash mismatch but can't identify the corrupted members, so only raise alarm for the least minority",
// If quorum doesn't exist, we don't know which members data are
// corrupted. In such situation, we intentionally set the memberID
// as 0, it means it affects the whole cluster.
cm.lg.Error("Detected compaction hash mismatch but cannot identify the corrupted members, so intentionally set the memberID as 0",
zap.String("leader-id", leaderId.String()),
zap.Int64("leader-revision", leaderHash.Revision),
zap.Int64("leader-compact-revision", leaderHash.CompactRevision),
zap.Uint32("leader-hash", leaderHash.Hash),
zap.Uint32("peer-hash", hashVal),
zap.String("peer-ids", memberIDs.String()),
)
cm.hasher.TriggerCorruptAlarm(0)
}

// Raise alarm for the left members if the quorum is present.
Expand All @@ -391,7 +370,7 @@ func (cm *corruptionChecker) checkPeerHashes(leaderHash mvcc.KeyValueHash, peers
zap.Uint32("leader-hash", leaderHash.Hash),
zap.Uint32("peer-hash", k),
zap.String("peer-ids", v.String()),
zap.Bool("alarm-raised", quorumExist),
zap.Bool("quorum-exist", quorumExist),
)
}

Expand Down

0 comments on commit 04775da

Please sign in to comment.