Skip to content

Commit dd7930f

Browse files
committed
Match error message correctly (tikv#887)
Signed-off-by: you06 <you1474600@gmail.com>
1 parent 563db30 commit dd7930f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

internal/locate/region_request.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,8 @@ func regionErrorToLabel(e *errorpb.Error) string {
14461446
return "flashback_in_progress"
14471447
} else if e.GetFlashbackNotPrepared() != nil {
14481448
return "flashback_not_prepared"
1449-
} else if strings.HasPrefix(e.Message, "mismatch peer id") {
1449+
} else if strings.Contains(e.Message, "mismatch peer id") {
1450+
// the error message is like "[components/raftstore/src/store/util.rs:428]: mismatch peer id ? != ?"
14501451
// the `mismatch peer id` error does not has a specific error type, so we have to match the error message.
14511452
// TODO: add a specific error type for `mismatch peer id`.
14521453
return "mismatch_peer_id"

internal/locate/region_request3_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaReadFallbackToLeaderReg
899899
// Return `mismatch peer id` when accesses the leader.
900900
if addr == s.cluster.GetStore(s.storeIDs[0]).Address {
901901
return &tikvrpc.Response{Resp: &kvrpcpb.GetResponse{RegionError: &errorpb.Error{
902-
Message: "mismatch peer id 1 != 2",
902+
Message: `"[components/raftstore/src/store/util.rs:428]: mismatch peer id 1 != 2"`,
903903
}}}, nil
904904
}
905905
return &tikvrpc.Response{Resp: &kvrpcpb.GetResponse{RegionError: &errorpb.Error{

0 commit comments

Comments
 (0)