33import io .dingodb .sdk .common .DingoClientException .ExhaustedRetryException ;
44import io .dingodb .sdk .common .DingoClientException .InvalidRouteTableException ;
55import io .dingodb .sdk .common .DingoClientException .RequestErrorException ;
6+ import io .dingodb .sdk .common .utils .ErrorCodeUtils ;
67import io .dingodb .sdk .service .JsonMessageUtils ;
78import io .dingodb .sdk .service .Caller ;
89import io .dingodb .sdk .service .ChannelProvider ;
1213import io .dingodb .sdk .service .entity .Message .Response ;
1314import io .dingodb .sdk .service .entity .error .Errno ;
1415import io .dingodb .sdk .service .entity .error .Error ;
16+ import io .dingodb .sdk .service .entity .store .TxnPrewriteResponse ;
1517import io .grpc .CallOptions ;
1618import io .grpc .Channel ;
1719import io .grpc .MethodDescriptor ;
2527import java .util .function .Function ;
2628
2729import static io .dingodb .sdk .common .utils .ErrorCodeUtils .errorToStrategy ;
30+ import static io .dingodb .sdk .common .utils .ErrorCodeUtils .isPreWriteRequestFailed ;
2831
2932@ Slf4j
3033public class ServiceCaller <S extends Service <S >> implements Caller <S > {
@@ -97,7 +100,8 @@ public <REQ extends Request, RES extends Response> RES call(
97100 channel .authority () + ">>" + error .getErrmsg (), (k , v ) -> v == null ? 1 : v + 1
98101 );
99102 switch (handler .onErrStrategy (
100- errorToStrategy (errCode ),
103+ isPreWriteRequestFailed (errCode , (response instanceof TxnPrewriteResponse )) ?
104+ ErrorCodeUtils .Strategy .FAILED : errorToStrategy (errCode ),
101105 this .retry , retry , request , response , options , channel .authority (), requestId
102106 )) {
103107 case RETRY :
@@ -123,7 +127,8 @@ public <REQ extends Request, RES extends Response> RES call(
123127 handler .onIgnore (request , response , options , channel .authority (), requestId );
124128 return null ;
125129 default :
126- throw new IllegalStateException ("Unexpected value: " + errorToStrategy (errCode ));
130+ throw new IllegalStateException ("Unexpected value: " + errorToStrategy (
131+ errCode ));
127132 }
128133 }
129134 handler .after (request , response , options , channel .authority (), requestId );
0 commit comments