Skip to content

Commit a3875bc

Browse files
authored
Match error message correctly (#887)
Signed-off-by: you06 <you1474600@gmail.com>
1 parent c7a847c commit a3875bc

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
@@ -1657,7 +1657,8 @@ func regionErrorToLabel(e *errorpb.Error) string {
16571657
return "flashback_not_prepared"
16581658
} else if e.GetIsWitness() != nil {
16591659
return "peer_is_witness"
1660-
} else if strings.HasPrefix(e.Message, "mismatch peer id") {
1660+
} else if strings.Contains(e.Message, "mismatch peer id") {
1661+
// the error message is like "[components/raftstore/src/store/util.rs:428]: mismatch peer id ? != ?"
16611662
// the `mismatch peer id` error does not has a specific error type, so we have to match the error message.
16621663
// TODO: add a specific error type for `mismatch peer id`.
16631664
return "mismatch_peer_id"

internal/locate/region_request3_test.go

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

0 commit comments

Comments
 (0)