From 76b14e4ec33c39f9ef12af4002e4e2a4eb4d7c4a Mon Sep 17 00:00:00 2001 From: Han Fei Date: Thu, 29 Apr 2021 17:38:46 +0800 Subject: [PATCH] mpp: support returning regions that need retry (#751) * mpp: support return of region errors * return region list Co-authored-by: Zhuhe Fang --- pkg/mpp/mpp.pb.go | 153 ++++++++++++++++++++++++++++++++-------------- proto/mpp.proto | 2 + 2 files changed, 109 insertions(+), 46 deletions(-) diff --git a/pkg/mpp/mpp.pb.go b/pkg/mpp/mpp.pb.go index 25c0a05fd..5197b97b6 100644 --- a/pkg/mpp/mpp.pb.go +++ b/pkg/mpp/mpp.pb.go @@ -13,6 +13,8 @@ import ( _ "github.com/gogo/protobuf/gogoproto" coprocessor "github.com/pingcap/kvproto/pkg/coprocessor" + + metapb "github.com/pingcap/kvproto/pkg/metapb" ) // Reference imports to suppress errors if they are not otherwise used. @@ -41,7 +43,7 @@ func (m *TaskMeta) Reset() { *m = TaskMeta{} } func (m *TaskMeta) String() string { return proto.CompactTextString(m) } func (*TaskMeta) ProtoMessage() {} func (*TaskMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_mpp_541af3e2b5468178, []int{0} + return fileDescriptor_mpp_3e13d8987123b211, []int{0} } func (m *TaskMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -115,7 +117,7 @@ func (m *DispatchTaskRequest) Reset() { *m = DispatchTaskRequest{} } func (m *DispatchTaskRequest) String() string { return proto.CompactTextString(m) } func (*DispatchTaskRequest) ProtoMessage() {} func (*DispatchTaskRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_mpp_541af3e2b5468178, []int{1} + return fileDescriptor_mpp_3e13d8987123b211, []int{1} } func (m *DispatchTaskRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -181,17 +183,18 @@ func (m *DispatchTaskRequest) GetSchemaVer() int64 { // Get response of DispatchTaskRequest. type DispatchTaskResponse struct { - Error *Error `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Error *Error `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"` + RetryRegions []*metapb.Region `protobuf:"bytes,2,rep,name=retry_regions,json=retryRegions" json:"retry_regions,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *DispatchTaskResponse) Reset() { *m = DispatchTaskResponse{} } func (m *DispatchTaskResponse) String() string { return proto.CompactTextString(m) } func (*DispatchTaskResponse) ProtoMessage() {} func (*DispatchTaskResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_mpp_541af3e2b5468178, []int{2} + return fileDescriptor_mpp_3e13d8987123b211, []int{2} } func (m *DispatchTaskResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -227,6 +230,13 @@ func (m *DispatchTaskResponse) GetError() *Error { return nil } +func (m *DispatchTaskResponse) GetRetryRegions() []*metapb.Region { + if m != nil { + return m.RetryRegions + } + return nil +} + // CancelTaskRequest closes the execution of a task. type CancelTaskRequest struct { Meta *TaskMeta `protobuf:"bytes,1,opt,name=meta" json:"meta,omitempty"` @@ -240,7 +250,7 @@ func (m *CancelTaskRequest) Reset() { *m = CancelTaskRequest{} } func (m *CancelTaskRequest) String() string { return proto.CompactTextString(m) } func (*CancelTaskRequest) ProtoMessage() {} func (*CancelTaskRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_mpp_541af3e2b5468178, []int{3} + return fileDescriptor_mpp_3e13d8987123b211, []int{3} } func (m *CancelTaskRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -294,7 +304,7 @@ func (m *CancelTaskResponse) Reset() { *m = CancelTaskResponse{} } func (m *CancelTaskResponse) String() string { return proto.CompactTextString(m) } func (*CancelTaskResponse) ProtoMessage() {} func (*CancelTaskResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_mpp_541af3e2b5468178, []int{4} + return fileDescriptor_mpp_3e13d8987123b211, []int{4} } func (m *CancelTaskResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -343,7 +353,7 @@ func (m *EstablishMPPConnectionRequest) Reset() { *m = EstablishMPPConne func (m *EstablishMPPConnectionRequest) String() string { return proto.CompactTextString(m) } func (*EstablishMPPConnectionRequest) ProtoMessage() {} func (*EstablishMPPConnectionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_mpp_541af3e2b5468178, []int{5} + return fileDescriptor_mpp_3e13d8987123b211, []int{5} } func (m *EstablishMPPConnectionRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -399,7 +409,7 @@ func (m *MPPDataPacket) Reset() { *m = MPPDataPacket{} } func (m *MPPDataPacket) String() string { return proto.CompactTextString(m) } func (*MPPDataPacket) ProtoMessage() {} func (*MPPDataPacket) Descriptor() ([]byte, []int) { - return fileDescriptor_mpp_541af3e2b5468178, []int{6} + return fileDescriptor_mpp_3e13d8987123b211, []int{6} } func (m *MPPDataPacket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -454,7 +464,7 @@ func (m *Error) Reset() { *m = Error{} } func (m *Error) String() string { return proto.CompactTextString(m) } func (*Error) ProtoMessage() {} func (*Error) Descriptor() ([]byte, []int) { - return fileDescriptor_mpp_541af3e2b5468178, []int{7} + return fileDescriptor_mpp_3e13d8987123b211, []int{7} } func (m *Error) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -633,6 +643,18 @@ func (m *DispatchTaskResponse) MarshalTo(dAtA []byte) (int, error) { } i += n2 } + if len(m.RetryRegions) > 0 { + for _, msg := range m.RetryRegions { + dAtA[i] = 0x12 + i++ + i = encodeVarintMpp(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -888,6 +910,12 @@ func (m *DispatchTaskResponse) Size() (n int) { l = m.Error.Size() n += 1 + l + sovMpp(uint64(l)) } + if len(m.RetryRegions) > 0 { + for _, e := range m.RetryRegions { + l = e.Size() + n += 1 + l + sovMpp(uint64(l)) + } + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -1370,6 +1398,37 @@ func (m *DispatchTaskResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RetryRegions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMpp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMpp + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RetryRegions = append(m.RetryRegions, &metapb.Region{}) + if err := m.RetryRegions[len(m.RetryRegions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipMpp(dAtA[iNdEx:]) @@ -2029,38 +2088,40 @@ var ( ErrIntOverflowMpp = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("mpp.proto", fileDescriptor_mpp_541af3e2b5468178) } - -var fileDescriptor_mpp_541af3e2b5468178 = []byte{ - // 479 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0x75, 0xd2, 0x34, 0xe3, 0x44, 0x6a, 0x97, 0x4a, 0x35, 0x95, 0x1a, 0xa5, 0x3e, 0xe5, - 0x82, 0x11, 0x41, 0x42, 0x9c, 0x69, 0x73, 0xc8, 0x21, 0x92, 0xb5, 0xaa, 0x10, 0x37, 0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0xfa, 0x0e, 0xdb, 0x72, 0xfb, - 0x34, 0x5c, 0x79, 0x9f, 0xbb, 0x98, 0x1d, 0x83, 0x5f, 0x53, 0xe1, 0x8a, 0x87, 0xdc, 0x86, 0xef, - 0xa3, 0x1f, 0xbb, 0x89, 0xf7, 0x73, 0x37, 0xf1, 0x7e, 0xed, 0x26, 0xde, 0xb7, 0xdf, 0x93, 0x67, - 0x70, 0xac, 0x74, 0x11, 0x9b, 0xb2, 0xda, 0xc6, 0xd5, 0xd6, 0x7d, 0x32, 0xb7, 0x87, 0xee, 0xe7, - 0xcd, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x5b, 0x9c, 0x8e, 0x74, 0x03, 0x00, 0x00, +func init() { proto.RegisterFile("mpp.proto", fileDescriptor_mpp_3e13d8987123b211) } + +var fileDescriptor_mpp_3e13d8987123b211 = []byte{ + // 509 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 0x6a, 0xdb, 0x40, + 0x10, 0xc6, 0x2b, 0xff, 0x89, 0xe3, 0x91, 0x52, 0x92, 0x6d, 0x20, 0x6a, 0x20, 0xc6, 0xd1, 0xc9, + 0x97, 0xaa, 0xd4, 0x81, 0x3e, 0x40, 0x13, 0x1f, 0x7c, 0x30, 0x88, 0x25, 0x94, 0xde, 0xc4, 0x5a, + 0x9a, 0xca, 0x42, 0xd6, 0xee, 0x76, 0x77, 0x63, 0x28, 0x3d, 0xf6, 0x25, 0xfa, 0x46, 0xed, 0xb1, + 0x8f, 0x50, 0xdc, 0x17, 0x29, 0xbb, 0x92, 0x42, 0x0a, 0x0d, 0xa4, 0x27, 0xcf, 0x37, 0xdf, 0xcc, + 0xee, 0x6f, 0xc6, 0x2b, 0x18, 0xd7, 0x52, 0xc6, 0x52, 0x09, 0x23, 0x48, 0xbf, 0x96, 0xf2, 0xfc, + 0xb4, 0x10, 0x85, 0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77, 0xd1, + 0x8f, 0xfd, 0xc4, 0xfb, 0xb9, 0x9f, 0x78, 0xbf, 0xf6, 0x13, 0xef, 0xdb, 0xef, 0xc9, 0x33, 0x38, + 0x16, 0xaa, 0x88, 0x4d, 0x59, 0xed, 0xe2, 0x6a, 0xe7, 0xbe, 0xb3, 0xf5, 0x81, 0xfb, 0xb9, 0xfa, + 0x13, 0x00, 0x00, 0xff, 0xff, 0xdf, 0xcc, 0xb2, 0x75, 0xb7, 0x03, 0x00, 0x00, } diff --git a/proto/mpp.proto b/proto/mpp.proto index c8a06dfa1..86725d26a 100644 --- a/proto/mpp.proto +++ b/proto/mpp.proto @@ -3,6 +3,7 @@ package mpp; import "gogoproto/gogo.proto"; import "coprocessor.proto"; +import "metapb.proto"; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; @@ -31,6 +32,7 @@ message DispatchTaskRequest { // Get response of DispatchTaskRequest. message DispatchTaskResponse { Error error = 1; + repeated metapb.Region retry_regions = 2; } // CancelTaskRequest closes the execution of a task.