Skip to content

Commit

Permalink
Match error message correctly (#887)
Browse files Browse the repository at this point in the history
Signed-off-by: you06 <you1474600@gmail.com>
  • Loading branch information
you06 authored Jul 13, 2023
1 parent c7a847c commit a3875bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/locate/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,8 @@ func regionErrorToLabel(e *errorpb.Error) string {
return "flashback_not_prepared"
} else if e.GetIsWitness() != nil {
return "peer_is_witness"
} else if strings.HasPrefix(e.Message, "mismatch peer id") {
} else if strings.Contains(e.Message, "mismatch peer id") {
// the error message is like "[components/raftstore/src/store/util.rs:428]: mismatch peer id ? != ?"
// the `mismatch peer id` error does not has a specific error type, so we have to match the error message.
// TODO: add a specific error type for `mismatch peer id`.
return "mismatch_peer_id"
Expand Down
2 changes: 1 addition & 1 deletion internal/locate/region_request3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaReadFallbackToLeaderReg
// Return `mismatch peer id` when accesses the leader.
if addr == s.cluster.GetStore(s.storeIDs[0]).Address {
return &tikvrpc.Response{Resp: &kvrpcpb.GetResponse{RegionError: &errorpb.Error{
Message: "mismatch peer id 1 != 2",
Message: `"[components/raftstore/src/store/util.rs:428]: mismatch peer id 1 != 2"`,
}}}, nil
}
return &tikvrpc.Response{Resp: &kvrpcpb.GetResponse{RegionError: &errorpb.Error{
Expand Down

0 comments on commit a3875bc

Please sign in to comment.