Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Oct 20, 2023
1 parent 7791814 commit 1316a22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions pkg/schedule/checker/rule_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ loopFits:
// Isdisconnected is more strictly than IsUnhealthy.
if c.cluster.GetStore(p.GetStoreId()).IsDisconnected() {
hasUnhealthyFit = true
pinDownPeer = p
break loopFits
}
}
Expand All @@ -481,6 +482,10 @@ loopFits:
if isUnhealthyPeer(orphanPeer.GetId()) {
continue
}
// make sure the orphan peer is not in disconnect store.
if c.cluster.GetStore(orphanPeer.GetStoreId()).IsDisconnected() {
continue
}
// no consider witness in this path.
if pinDownPeer.GetIsWitness() || orphanPeer.GetIsWitness() {
continue
Expand All @@ -500,6 +505,8 @@ loopFits:
return operator.CreatePromoteLearnerOperatorAndRemovePeer("replace-down-peer-with-orphan-peer", c.cluster, region, orphanPeer, pinDownPeer)
case orphanPeerRole == metapb.PeerRole_Voter && destRole == metapb.PeerRole_Learner:
return operator.CreateDemoteLearnerOperatorAndRemovePeer("replace-down-peer-with-orphan-peer", c.cluster, region, orphanPeer, pinDownPeer)
case orphanPeerRole == metapb.PeerRole_Voter && destRole == metapb.PeerRole_Voter:
return operator.CreateRemovePeerOperator("remove-orphan-peer", c.cluster, 0, region, pinDownPeer.GetStoreId())
default:
// destRole should not same with orphanPeerRole. if role is same, it fit with orphanPeer should be better than now.
// destRole never be leader, so we not consider it.
Expand All @@ -522,10 +529,7 @@ loopFits:
ruleCheckerRemoveOrphanPeerCounter.Inc()
return operator.CreateRemovePeerOperator("remove-orphan-peer", c.cluster, 0, region, orphanPeer.StoreId)
}
// If the store is disconnected, we cannot be sure whether it is healthy.
if !c.cluster.GetStore(orphanPeer.GetStoreId()).IsDisconnected() {
hasHealthPeer = true
}
hasHealthPeer = true
}
}
ruleCheckerSkipRemoveOrphanPeerCounter.Inc()
Expand Down
2 changes: 1 addition & 1 deletion server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2796,7 +2796,7 @@ func TestReplica(t *testing.T) {
re.NoError(tc.addLeaderRegion(2, 1, 2, 3, 4))
region = tc.GetRegion(2)
re.NoError(dispatchHeartbeat(co, region, stream))
region = waitRemovePeer(re, stream, region, 4)
region = waitRemovePeer(re, stream, region, 3) // store3 is down, we should remove it firstly.
re.NoError(dispatchHeartbeat(co, region, stream))
waitNoResponse(re, stream)

Expand Down

0 comments on commit 1316a22

Please sign in to comment.