From 6e4d6f0536811fd5c78bc371f3b985354aa06f21 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Mon, 12 Jul 2021 10:06:28 -0400 Subject: [PATCH 1/3] Remove vtrpc.LegacyErrorCode It has been "legacy" for 4 years now, so it should be safe to just drop. Signed-off-by: Andrew Mason --- go/sqltypes/proto3_test.go | 5 +- go/vt/proto/vtrpc/vtrpc.pb.go | 252 ++++--------------- go/vt/proto/vtrpc/vtrpc_vtproto.pb.go | 27 -- go/vt/vterrors/grpc.go | 70 ------ go/vt/vterrors/proto3.go | 12 +- go/vt/vterrors/proto3_test.go | 14 +- go/vt/vttablet/tabletconn/grpc_error.go | 6 +- go/vt/vttablet/tabletconn/grpc_error_test.go | 9 +- proto/vtrpc.proto | 82 +----- web/vtadmin/src/proto/vtadmin.d.ts | 23 -- web/vtadmin/src/proto/vtadmin.js | 126 ---------- 11 files changed, 60 insertions(+), 566 deletions(-) diff --git a/go/sqltypes/proto3_test.go b/go/sqltypes/proto3_test.go index efa7b10a74b..5e0bffd2a73 100644 --- a/go/sqltypes/proto3_test.go +++ b/go/sqltypes/proto3_test.go @@ -229,9 +229,8 @@ func TestQueryReponses(t *testing.T) { }, }, { Error: &vtrpcpb.RPCError{ - LegacyCode: vtrpcpb.LegacyErrorCode_DEADLINE_EXCEEDED_LEGACY, - Message: "deadline exceeded", - Code: vtrpcpb.Code_DEADLINE_EXCEEDED, + Message: "deadline exceeded", + Code: vtrpcpb.Code_DEADLINE_EXCEEDED, }, Result: nil, }, diff --git a/go/vt/proto/vtrpc/vtrpc.pb.go b/go/vt/proto/vtrpc/vtrpc.pb.go index e419d68adcf..2b30a70ba17 100644 --- a/go/vt/proto/vtrpc/vtrpc.pb.go +++ b/go/vt/proto/vtrpc/vtrpc.pb.go @@ -213,137 +213,6 @@ func (Code) EnumDescriptor() ([]byte, []int) { return file_vtrpc_proto_rawDescGZIP(), []int{0} } -// LegacyErrorCode is the enum values for Errors. This type is deprecated. -// Use Code instead. Background: In the initial design, we thought -// that we may end up with a different list of canonical error codes -// than the ones defined by grpc. In hindsight, we realize that -// the grpc error codes are fairly generic and mostly sufficient. -// In order to avoid confusion, this type will be deprecated in -// favor of the new Code that matches exactly what grpc defines. -// Some names below have a _LEGACY suffix. This is to prevent -// name collisions with Code. -type LegacyErrorCode int32 - -const ( - // SUCCESS_LEGACY is returned from a successful call. - LegacyErrorCode_SUCCESS_LEGACY LegacyErrorCode = 0 - // CANCELLED_LEGACY means that the context was cancelled (and noticed in the app layer, - // as opposed to the RPC layer). - LegacyErrorCode_CANCELLED_LEGACY LegacyErrorCode = 1 - // UNKNOWN_ERROR_LEGACY includes: - // 1. MySQL error codes that we don't explicitly handle. - // 2. MySQL response that wasn't as expected. For example, we might expect a MySQL - // timestamp to be returned in a particular way, but it wasn't. - // 3. Anything else that doesn't fall into a different bucket. - LegacyErrorCode_UNKNOWN_ERROR_LEGACY LegacyErrorCode = 2 - // BAD_INPUT_LEGACY is returned when an end-user either sends SQL that couldn't be parsed correctly, - // or tries a query that isn't supported by Vitess. - LegacyErrorCode_BAD_INPUT_LEGACY LegacyErrorCode = 3 - // DEADLINE_EXCEEDED_LEGACY is returned when an action is taking longer than a given timeout. - LegacyErrorCode_DEADLINE_EXCEEDED_LEGACY LegacyErrorCode = 4 - // INTEGRITY_ERROR_LEGACY is returned on integrity error from MySQL, usually due to - // duplicate primary keys. - LegacyErrorCode_INTEGRITY_ERROR_LEGACY LegacyErrorCode = 5 - // PERMISSION_DENIED_LEGACY errors are returned when a user requests access to something - // that they don't have permissions for. - LegacyErrorCode_PERMISSION_DENIED_LEGACY LegacyErrorCode = 6 - // RESOURCE_EXHAUSTED_LEGACY is returned when a query exceeds its quota in some dimension - // and can't be completed due to that. Queries that return RESOURCE_EXHAUSTED - // should not be retried, as it could be detrimental to the server's health. - // Examples of errors that will cause the RESOURCE_EXHAUSTED code: - // 1. TxPoolFull: this is retried server-side, and is only returned as an error - // if the server-side retries failed. - // 2. Query is killed due to it taking too long. - LegacyErrorCode_RESOURCE_EXHAUSTED_LEGACY LegacyErrorCode = 7 - // QUERY_NOT_SERVED_LEGACY means that a query could not be served right now. - // Client can interpret it as: "the tablet that you sent this query to cannot - // serve the query right now, try a different tablet or try again later." - // This could be due to various reasons: QueryService is not serving, should - // not be serving, wrong shard, wrong tablet type, table is part of the denylist, etc. - // Clients that receive this error should usually retry the query, but after taking - // the appropriate steps to make sure that the query will get sent to the correct - // tablet. - LegacyErrorCode_QUERY_NOT_SERVED_LEGACY LegacyErrorCode = 8 - // NOT_IN_TX_LEGACY means that we're not currently in a transaction, but we should be. - LegacyErrorCode_NOT_IN_TX_LEGACY LegacyErrorCode = 9 - // INTERNAL_ERROR_LEGACY means some invariants expected by underlying - // system has been broken. If you see one of these errors, - // something is very broken. - LegacyErrorCode_INTERNAL_ERROR_LEGACY LegacyErrorCode = 10 - // TRANSIENT_ERROR_LEGACY is used for when there is some error that we expect we can - // recover from automatically - often due to a resource limit temporarily being - // reached. Retrying this error, with an exponential backoff, should succeed. - // Clients should be able to successfully retry the query on the same backends. - // Examples of things that can trigger this error: - // 1. Query has been throttled - // 2. VtGate could have request backlog - LegacyErrorCode_TRANSIENT_ERROR_LEGACY LegacyErrorCode = 11 - // UNAUTHENTICATED_LEGACY errors are returned when a user requests access to something, - // and we're unable to verify the user's authentication. - LegacyErrorCode_UNAUTHENTICATED_LEGACY LegacyErrorCode = 12 -) - -// Enum value maps for LegacyErrorCode. -var ( - LegacyErrorCode_name = map[int32]string{ - 0: "SUCCESS_LEGACY", - 1: "CANCELLED_LEGACY", - 2: "UNKNOWN_ERROR_LEGACY", - 3: "BAD_INPUT_LEGACY", - 4: "DEADLINE_EXCEEDED_LEGACY", - 5: "INTEGRITY_ERROR_LEGACY", - 6: "PERMISSION_DENIED_LEGACY", - 7: "RESOURCE_EXHAUSTED_LEGACY", - 8: "QUERY_NOT_SERVED_LEGACY", - 9: "NOT_IN_TX_LEGACY", - 10: "INTERNAL_ERROR_LEGACY", - 11: "TRANSIENT_ERROR_LEGACY", - 12: "UNAUTHENTICATED_LEGACY", - } - LegacyErrorCode_value = map[string]int32{ - "SUCCESS_LEGACY": 0, - "CANCELLED_LEGACY": 1, - "UNKNOWN_ERROR_LEGACY": 2, - "BAD_INPUT_LEGACY": 3, - "DEADLINE_EXCEEDED_LEGACY": 4, - "INTEGRITY_ERROR_LEGACY": 5, - "PERMISSION_DENIED_LEGACY": 6, - "RESOURCE_EXHAUSTED_LEGACY": 7, - "QUERY_NOT_SERVED_LEGACY": 8, - "NOT_IN_TX_LEGACY": 9, - "INTERNAL_ERROR_LEGACY": 10, - "TRANSIENT_ERROR_LEGACY": 11, - "UNAUTHENTICATED_LEGACY": 12, - } -) - -func (x LegacyErrorCode) Enum() *LegacyErrorCode { - p := new(LegacyErrorCode) - *p = x - return p -} - -func (x LegacyErrorCode) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (LegacyErrorCode) Descriptor() protoreflect.EnumDescriptor { - return file_vtrpc_proto_enumTypes[1].Descriptor() -} - -func (LegacyErrorCode) Type() protoreflect.EnumType { - return &file_vtrpc_proto_enumTypes[1] -} - -func (x LegacyErrorCode) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use LegacyErrorCode.Descriptor instead. -func (LegacyErrorCode) EnumDescriptor() ([]byte, []int) { - return file_vtrpc_proto_rawDescGZIP(), []int{1} -} - // CallerID is passed along RPCs to identify the originating client // for a request. It is not meant to be secure, but only // informational. The client can put whatever info they want in these @@ -435,9 +304,8 @@ type RPCError struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - LegacyCode LegacyErrorCode `protobuf:"varint,1,opt,name=legacy_code,json=legacyCode,proto3,enum=vtrpc.LegacyErrorCode" json:"legacy_code,omitempty"` - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - Code Code `protobuf:"varint,3,opt,name=code,proto3,enum=vtrpc.Code" json:"code,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + Code Code `protobuf:"varint,3,opt,name=code,proto3,enum=vtrpc.Code" json:"code,omitempty"` } func (x *RPCError) Reset() { @@ -472,13 +340,6 @@ func (*RPCError) Descriptor() ([]byte, []int) { return file_vtrpc_proto_rawDescGZIP(), []int{1} } -func (x *RPCError) GetLegacyCode() LegacyErrorCode { - if x != nil { - return x.LegacyCode - } - return LegacyErrorCode_SUCCESS_LEGACY -} - func (x *RPCError) GetMessage() string { if x != nil { return x.Message @@ -504,61 +365,36 @@ var file_vtrpc_proto_rawDesc = []byte{ 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x75, 0x62, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, - 0x22, 0x7e, 0x0a, 0x08, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x37, 0x0a, 0x0b, - 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x16, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x0a, 0x6c, 0x65, 0x67, 0x61, 0x63, - 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x1f, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, - 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, - 0x2a, 0xb6, 0x02, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x4f, 0x4b, 0x10, - 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x12, - 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, - 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x41, 0x52, 0x47, 0x55, 0x4d, 0x45, 0x4e, 0x54, - 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x44, 0x45, 0x41, 0x44, 0x4c, 0x49, 0x4e, 0x45, 0x5f, 0x45, - 0x58, 0x43, 0x45, 0x45, 0x44, 0x45, 0x44, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x4f, 0x54, - 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x05, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x4c, 0x52, 0x45, - 0x41, 0x44, 0x59, 0x5f, 0x45, 0x58, 0x49, 0x53, 0x54, 0x53, 0x10, 0x06, 0x12, 0x15, 0x0a, 0x11, - 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x4e, 0x49, 0x45, - 0x44, 0x10, 0x07, 0x12, 0x13, 0x0a, 0x0f, 0x55, 0x4e, 0x41, 0x55, 0x54, 0x48, 0x45, 0x4e, 0x54, - 0x49, 0x43, 0x41, 0x54, 0x45, 0x44, 0x10, 0x10, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x45, 0x53, 0x4f, - 0x55, 0x52, 0x43, 0x45, 0x5f, 0x45, 0x58, 0x48, 0x41, 0x55, 0x53, 0x54, 0x45, 0x44, 0x10, 0x08, - 0x12, 0x17, 0x0a, 0x13, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x5f, 0x50, 0x52, 0x45, 0x43, 0x4f, - 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x09, 0x12, 0x0b, 0x0a, 0x07, 0x41, 0x42, 0x4f, - 0x52, 0x54, 0x45, 0x44, 0x10, 0x0a, 0x12, 0x10, 0x0a, 0x0c, 0x4f, 0x55, 0x54, 0x5f, 0x4f, 0x46, - 0x5f, 0x52, 0x41, 0x4e, 0x47, 0x45, 0x10, 0x0b, 0x12, 0x11, 0x0a, 0x0d, 0x55, 0x4e, 0x49, 0x4d, - 0x50, 0x4c, 0x45, 0x4d, 0x45, 0x4e, 0x54, 0x45, 0x44, 0x10, 0x0c, 0x12, 0x0c, 0x0a, 0x08, 0x49, - 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x10, 0x0d, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x41, - 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x0e, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x41, - 0x54, 0x41, 0x5f, 0x4c, 0x4f, 0x53, 0x53, 0x10, 0x0f, 0x2a, 0xe8, 0x02, 0x0a, 0x0f, 0x4c, 0x65, - 0x67, 0x61, 0x63, 0x79, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, - 0x0e, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, - 0x00, 0x12, 0x14, 0x0a, 0x10, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x4c, 0x45, 0x44, 0x5f, 0x4c, - 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, - 0x57, 0x4e, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, - 0x02, 0x12, 0x14, 0x0a, 0x10, 0x42, 0x41, 0x44, 0x5f, 0x49, 0x4e, 0x50, 0x55, 0x54, 0x5f, 0x4c, - 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18, 0x44, 0x45, 0x41, 0x44, 0x4c, - 0x49, 0x4e, 0x45, 0x5f, 0x45, 0x58, 0x43, 0x45, 0x45, 0x44, 0x45, 0x44, 0x5f, 0x4c, 0x45, 0x47, - 0x41, 0x43, 0x59, 0x10, 0x04, 0x12, 0x1a, 0x0a, 0x16, 0x49, 0x4e, 0x54, 0x45, 0x47, 0x52, 0x49, - 0x54, 0x59, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, - 0x05, 0x12, 0x1c, 0x0a, 0x18, 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, - 0x44, 0x45, 0x4e, 0x49, 0x45, 0x44, 0x5f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, 0x06, 0x12, - 0x1d, 0x0a, 0x19, 0x52, 0x45, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x45, 0x58, 0x48, 0x41, - 0x55, 0x53, 0x54, 0x45, 0x44, 0x5f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, 0x07, 0x12, 0x1b, - 0x0a, 0x17, 0x51, 0x55, 0x45, 0x52, 0x59, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x53, 0x45, 0x52, 0x56, - 0x45, 0x44, 0x5f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, 0x08, 0x12, 0x14, 0x0a, 0x10, 0x4e, - 0x4f, 0x54, 0x5f, 0x49, 0x4e, 0x5f, 0x54, 0x58, 0x5f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, - 0x09, 0x12, 0x19, 0x0a, 0x15, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x5f, 0x45, 0x52, - 0x52, 0x4f, 0x52, 0x5f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, 0x0a, 0x12, 0x1a, 0x0a, 0x16, - 0x54, 0x52, 0x41, 0x4e, 0x53, 0x49, 0x45, 0x4e, 0x54, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, - 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, 0x0b, 0x12, 0x1a, 0x0a, 0x16, 0x55, 0x4e, 0x41, 0x55, - 0x54, 0x48, 0x45, 0x4e, 0x54, 0x49, 0x43, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x4c, 0x45, 0x47, 0x41, - 0x43, 0x59, 0x10, 0x0c, 0x42, 0x35, 0x0a, 0x0f, 0x69, 0x6f, 0x2e, 0x76, 0x69, 0x74, 0x65, 0x73, - 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x22, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, - 0x69, 0x6f, 0x2f, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x22, 0x58, 0x0a, 0x08, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x18, 0x0a, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x64, + 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x52, 0x0b, 0x6c, + 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0xb6, 0x02, 0x0a, 0x04, 0x43, + 0x6f, 0x64, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x4f, 0x4b, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x43, + 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, + 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, + 0x44, 0x5f, 0x41, 0x52, 0x47, 0x55, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, + 0x44, 0x45, 0x41, 0x44, 0x4c, 0x49, 0x4e, 0x45, 0x5f, 0x45, 0x58, 0x43, 0x45, 0x45, 0x44, 0x45, + 0x44, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, + 0x10, 0x05, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x4c, 0x52, 0x45, 0x41, 0x44, 0x59, 0x5f, 0x45, 0x58, + 0x49, 0x53, 0x54, 0x53, 0x10, 0x06, 0x12, 0x15, 0x0a, 0x11, 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, + 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x4e, 0x49, 0x45, 0x44, 0x10, 0x07, 0x12, 0x13, 0x0a, + 0x0f, 0x55, 0x4e, 0x41, 0x55, 0x54, 0x48, 0x45, 0x4e, 0x54, 0x49, 0x43, 0x41, 0x54, 0x45, 0x44, + 0x10, 0x10, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x45, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x45, + 0x58, 0x48, 0x41, 0x55, 0x53, 0x54, 0x45, 0x44, 0x10, 0x08, 0x12, 0x17, 0x0a, 0x13, 0x46, 0x41, + 0x49, 0x4c, 0x45, 0x44, 0x5f, 0x50, 0x52, 0x45, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, + 0x4e, 0x10, 0x09, 0x12, 0x0b, 0x0a, 0x07, 0x41, 0x42, 0x4f, 0x52, 0x54, 0x45, 0x44, 0x10, 0x0a, + 0x12, 0x10, 0x0a, 0x0c, 0x4f, 0x55, 0x54, 0x5f, 0x4f, 0x46, 0x5f, 0x52, 0x41, 0x4e, 0x47, 0x45, + 0x10, 0x0b, 0x12, 0x11, 0x0a, 0x0d, 0x55, 0x4e, 0x49, 0x4d, 0x50, 0x4c, 0x45, 0x4d, 0x45, 0x4e, + 0x54, 0x45, 0x44, 0x10, 0x0c, 0x12, 0x0c, 0x0a, 0x08, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, + 0x4c, 0x10, 0x0d, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, + 0x4c, 0x45, 0x10, 0x0e, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x41, 0x54, 0x41, 0x5f, 0x4c, 0x4f, 0x53, + 0x53, 0x10, 0x0f, 0x42, 0x35, 0x0a, 0x0f, 0x69, 0x6f, 0x2e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x22, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x69, + 0x6f, 0x2f, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -573,22 +409,20 @@ func file_vtrpc_proto_rawDescGZIP() []byte { return file_vtrpc_proto_rawDescData } -var file_vtrpc_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_vtrpc_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_vtrpc_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_vtrpc_proto_goTypes = []interface{}{ - (Code)(0), // 0: vtrpc.Code - (LegacyErrorCode)(0), // 1: vtrpc.LegacyErrorCode - (*CallerID)(nil), // 2: vtrpc.CallerID - (*RPCError)(nil), // 3: vtrpc.RPCError + (Code)(0), // 0: vtrpc.Code + (*CallerID)(nil), // 1: vtrpc.CallerID + (*RPCError)(nil), // 2: vtrpc.RPCError } var file_vtrpc_proto_depIdxs = []int32{ - 1, // 0: vtrpc.RPCError.legacy_code:type_name -> vtrpc.LegacyErrorCode - 0, // 1: vtrpc.RPCError.code:type_name -> vtrpc.Code - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 0, // 0: vtrpc.RPCError.code:type_name -> vtrpc.Code + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_vtrpc_proto_init() } @@ -627,7 +461,7 @@ func file_vtrpc_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_vtrpc_proto_rawDesc, - NumEnums: 2, + NumEnums: 1, NumMessages: 2, NumExtensions: 0, NumServices: 0, diff --git a/go/vt/proto/vtrpc/vtrpc_vtproto.pb.go b/go/vt/proto/vtrpc/vtrpc_vtproto.pb.go index 3e459b96f1e..ada9df5706e 100644 --- a/go/vt/proto/vtrpc/vtrpc_vtproto.pb.go +++ b/go/vt/proto/vtrpc/vtrpc_vtproto.pb.go @@ -114,11 +114,6 @@ func (m *RPCError) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if m.LegacyCode != 0 { - i = encodeVarint(dAtA, i, uint64(m.LegacyCode)) - i-- - dAtA[i] = 0x8 - } return len(dAtA) - i, nil } @@ -163,9 +158,6 @@ func (m *RPCError) SizeVT() (n int) { } var l int _ = l - if m.LegacyCode != 0 { - n += 1 + sov(uint64(m.LegacyCode)) - } l = len(m.Message) if l > 0 { n += 1 + l + sov(uint64(l)) @@ -361,25 +353,6 @@ func (m *RPCError) UnmarshalVT(dAtA []byte) error { return fmt.Errorf("proto: RPCError: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LegacyCode", wireType) - } - m.LegacyCode = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LegacyCode |= LegacyErrorCode(b&0x7F) << shift - if b < 0x80 { - break - } - } case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) diff --git a/go/vt/vterrors/grpc.go b/go/vt/vterrors/grpc.go index 640e37c6d13..c8c0eb20f1f 100644 --- a/go/vt/vterrors/grpc.go +++ b/go/vt/vterrors/grpc.go @@ -30,76 +30,6 @@ import ( // Use these methods to return an error through gRPC and still // retain its code. -// CodeToLegacyErrorCode maps a vtrpcpb.Code to a vtrpcpb.LegacyErrorCode. -func CodeToLegacyErrorCode(code vtrpcpb.Code) vtrpcpb.LegacyErrorCode { - switch code { - case vtrpcpb.Code_OK: - return vtrpcpb.LegacyErrorCode_SUCCESS_LEGACY - case vtrpcpb.Code_CANCELED: - return vtrpcpb.LegacyErrorCode_CANCELLED_LEGACY - case vtrpcpb.Code_UNKNOWN: - return vtrpcpb.LegacyErrorCode_UNKNOWN_ERROR_LEGACY - case vtrpcpb.Code_INVALID_ARGUMENT: - return vtrpcpb.LegacyErrorCode_BAD_INPUT_LEGACY - case vtrpcpb.Code_DEADLINE_EXCEEDED: - return vtrpcpb.LegacyErrorCode_DEADLINE_EXCEEDED_LEGACY - case vtrpcpb.Code_ALREADY_EXISTS: - return vtrpcpb.LegacyErrorCode_INTEGRITY_ERROR_LEGACY - case vtrpcpb.Code_PERMISSION_DENIED: - return vtrpcpb.LegacyErrorCode_PERMISSION_DENIED_LEGACY - case vtrpcpb.Code_RESOURCE_EXHAUSTED: - return vtrpcpb.LegacyErrorCode_RESOURCE_EXHAUSTED_LEGACY - case vtrpcpb.Code_FAILED_PRECONDITION: - return vtrpcpb.LegacyErrorCode_QUERY_NOT_SERVED_LEGACY - case vtrpcpb.Code_ABORTED: - return vtrpcpb.LegacyErrorCode_NOT_IN_TX_LEGACY - case vtrpcpb.Code_INTERNAL: - return vtrpcpb.LegacyErrorCode_INTERNAL_ERROR_LEGACY - case vtrpcpb.Code_UNAVAILABLE: - // Legacy code assumes Unavailable errors are sent as Internal. - return vtrpcpb.LegacyErrorCode_INTERNAL_ERROR_LEGACY - case vtrpcpb.Code_UNAUTHENTICATED: - return vtrpcpb.LegacyErrorCode_UNAUTHENTICATED_LEGACY - default: - return vtrpcpb.LegacyErrorCode_UNKNOWN_ERROR_LEGACY - } -} - -// LegacyErrorCodeToCode maps a vtrpcpb.LegacyErrorCode to a gRPC vtrpcpb.Code. -func LegacyErrorCodeToCode(code vtrpcpb.LegacyErrorCode) vtrpcpb.Code { - switch code { - case vtrpcpb.LegacyErrorCode_SUCCESS_LEGACY: - return vtrpcpb.Code_OK - case vtrpcpb.LegacyErrorCode_CANCELLED_LEGACY: - return vtrpcpb.Code_CANCELED - case vtrpcpb.LegacyErrorCode_UNKNOWN_ERROR_LEGACY: - return vtrpcpb.Code_UNKNOWN - case vtrpcpb.LegacyErrorCode_BAD_INPUT_LEGACY: - return vtrpcpb.Code_INVALID_ARGUMENT - case vtrpcpb.LegacyErrorCode_DEADLINE_EXCEEDED_LEGACY: - return vtrpcpb.Code_DEADLINE_EXCEEDED - case vtrpcpb.LegacyErrorCode_INTEGRITY_ERROR_LEGACY: - return vtrpcpb.Code_ALREADY_EXISTS - case vtrpcpb.LegacyErrorCode_PERMISSION_DENIED_LEGACY: - return vtrpcpb.Code_PERMISSION_DENIED - case vtrpcpb.LegacyErrorCode_RESOURCE_EXHAUSTED_LEGACY: - return vtrpcpb.Code_RESOURCE_EXHAUSTED - case vtrpcpb.LegacyErrorCode_QUERY_NOT_SERVED_LEGACY: - return vtrpcpb.Code_FAILED_PRECONDITION - case vtrpcpb.LegacyErrorCode_NOT_IN_TX_LEGACY: - return vtrpcpb.Code_ABORTED - case vtrpcpb.LegacyErrorCode_INTERNAL_ERROR_LEGACY: - // Legacy code sends internal error instead of Unavailable. - return vtrpcpb.Code_UNAVAILABLE - case vtrpcpb.LegacyErrorCode_TRANSIENT_ERROR_LEGACY: - return vtrpcpb.Code_UNAVAILABLE - case vtrpcpb.LegacyErrorCode_UNAUTHENTICATED_LEGACY: - return vtrpcpb.Code_UNAUTHENTICATED - default: - return vtrpcpb.Code_UNKNOWN - } -} - // truncateError shortens errors because gRPC has a size restriction on them. func truncateError(err error) string { // For more details see: https://github.com/grpc/grpc-go/issues/443 diff --git a/go/vt/vterrors/proto3.go b/go/vt/vterrors/proto3.go index 1f59eabd6a2..950f4274db3 100644 --- a/go/vt/vterrors/proto3.go +++ b/go/vt/vterrors/proto3.go @@ -31,11 +31,7 @@ func FromVTRPC(rpcErr *vtrpcpb.RPCError) error { if rpcErr == nil { return nil } - code := rpcErr.Code - if code == vtrpcpb.Code_OK { - code = LegacyErrorCodeToCode(rpcErr.LegacyCode) - } - return New(code, rpcErr.Message) + return New(rpcErr.Code, rpcErr.Message) } // ToVTRPC converts from vtError to a vtrpcpb.RPCError. @@ -43,10 +39,8 @@ func ToVTRPC(err error) *vtrpcpb.RPCError { if err == nil { return nil } - code := Code(err) return &vtrpcpb.RPCError{ - LegacyCode: CodeToLegacyErrorCode(code), - Code: code, - Message: err.Error(), + Code: Code(err), + Message: err.Error(), } } diff --git a/go/vt/vterrors/proto3_test.go b/go/vt/vterrors/proto3_test.go index 798aff02a86..4f06e8d2ada 100644 --- a/go/vt/vterrors/proto3_test.go +++ b/go/vt/vterrors/proto3_test.go @@ -33,15 +33,14 @@ func TestFromVtRPCError(t *testing.T) { want: nil, }, { in: &vtrpcpb.RPCError{ - LegacyCode: vtrpcpb.LegacyErrorCode_BAD_INPUT_LEGACY, - Message: "bad input", + Code: vtrpcpb.Code_INVALID_ARGUMENT, + Message: "bad input", }, want: New(vtrpcpb.Code_INVALID_ARGUMENT, "bad input"), }, { in: &vtrpcpb.RPCError{ - LegacyCode: vtrpcpb.LegacyErrorCode_BAD_INPUT_LEGACY, - Message: "bad input", - Code: vtrpcpb.Code_INVALID_ARGUMENT, + Message: "bad input", + Code: vtrpcpb.Code_INVALID_ARGUMENT, }, want: New(vtrpcpb.Code_INVALID_ARGUMENT, "bad input"), }, { @@ -69,9 +68,8 @@ func TestVtRPCErrorFromVtError(t *testing.T) { }, { in: New(vtrpcpb.Code_INVALID_ARGUMENT, "bad input"), want: &vtrpcpb.RPCError{ - LegacyCode: vtrpcpb.LegacyErrorCode_BAD_INPUT_LEGACY, - Message: "bad input", - Code: vtrpcpb.Code_INVALID_ARGUMENT, + Message: "bad input", + Code: vtrpcpb.Code_INVALID_ARGUMENT, }, }} for _, tcase := range testcases { diff --git a/go/vt/vttablet/tabletconn/grpc_error.go b/go/vt/vttablet/tabletconn/grpc_error.go index 44b8c5c2391..98e10948f6b 100644 --- a/go/vt/vttablet/tabletconn/grpc_error.go +++ b/go/vt/vttablet/tabletconn/grpc_error.go @@ -47,9 +47,5 @@ func ErrorFromVTRPC(err *vtrpcpb.RPCError) error { if err == nil { return nil } - code := err.Code - if code == vtrpcpb.Code_OK { - code = vterrors.LegacyErrorCodeToCode(err.LegacyCode) - } - return vterrors.Errorf(code, "vttablet: %s", err.Message) + return vterrors.Errorf(err.Code, "vttablet: %s", err.Message) } diff --git a/go/vt/vttablet/tabletconn/grpc_error_test.go b/go/vt/vttablet/tabletconn/grpc_error_test.go index 2fb864d8511..daf3ee3306c 100644 --- a/go/vt/vttablet/tabletconn/grpc_error_test.go +++ b/go/vt/vttablet/tabletconn/grpc_error_test.go @@ -29,15 +29,14 @@ func TestTabletErrorFromRPCError(t *testing.T) { want vtrpcpb.Code }{{ in: &vtrpcpb.RPCError{ - LegacyCode: vtrpcpb.LegacyErrorCode_BAD_INPUT_LEGACY, - Message: "bad input", + Code: vtrpcpb.Code_INVALID_ARGUMENT, + Message: "bad input", }, want: vtrpcpb.Code_INVALID_ARGUMENT, }, { in: &vtrpcpb.RPCError{ - LegacyCode: vtrpcpb.LegacyErrorCode_BAD_INPUT_LEGACY, - Message: "bad input", - Code: vtrpcpb.Code_INVALID_ARGUMENT, + Message: "bad input", + Code: vtrpcpb.Code_INVALID_ARGUMENT, }, want: vtrpcpb.Code_INVALID_ARGUMENT, }, { diff --git a/proto/vtrpc.proto b/proto/vtrpc.proto index b1360c904a5..0228f36ba2e 100644 --- a/proto/vtrpc.proto +++ b/proto/vtrpc.proto @@ -171,92 +171,12 @@ enum Code { DATA_LOSS = 15; } -// LegacyErrorCode is the enum values for Errors. This type is deprecated. -// Use Code instead. Background: In the initial design, we thought -// that we may end up with a different list of canonical error codes -// than the ones defined by grpc. In hindsight, we realize that -// the grpc error codes are fairly generic and mostly sufficient. -// In order to avoid confusion, this type will be deprecated in -// favor of the new Code that matches exactly what grpc defines. -// Some names below have a _LEGACY suffix. This is to prevent -// name collisions with Code. -enum LegacyErrorCode { - // SUCCESS_LEGACY is returned from a successful call. - SUCCESS_LEGACY = 0; - - // CANCELLED_LEGACY means that the context was cancelled (and noticed in the app layer, - // as opposed to the RPC layer). - CANCELLED_LEGACY = 1; - - // UNKNOWN_ERROR_LEGACY includes: - // 1. MySQL error codes that we don't explicitly handle. - // 2. MySQL response that wasn't as expected. For example, we might expect a MySQL - // timestamp to be returned in a particular way, but it wasn't. - // 3. Anything else that doesn't fall into a different bucket. - UNKNOWN_ERROR_LEGACY = 2; - - // BAD_INPUT_LEGACY is returned when an end-user either sends SQL that couldn't be parsed correctly, - // or tries a query that isn't supported by Vitess. - BAD_INPUT_LEGACY = 3; - - // DEADLINE_EXCEEDED_LEGACY is returned when an action is taking longer than a given timeout. - DEADLINE_EXCEEDED_LEGACY = 4; - - // INTEGRITY_ERROR_LEGACY is returned on integrity error from MySQL, usually due to - // duplicate primary keys. - INTEGRITY_ERROR_LEGACY = 5; - - // PERMISSION_DENIED_LEGACY errors are returned when a user requests access to something - // that they don't have permissions for. - PERMISSION_DENIED_LEGACY = 6; - - // RESOURCE_EXHAUSTED_LEGACY is returned when a query exceeds its quota in some dimension - // and can't be completed due to that. Queries that return RESOURCE_EXHAUSTED - // should not be retried, as it could be detrimental to the server's health. - // Examples of errors that will cause the RESOURCE_EXHAUSTED code: - // 1. TxPoolFull: this is retried server-side, and is only returned as an error - // if the server-side retries failed. - // 2. Query is killed due to it taking too long. - RESOURCE_EXHAUSTED_LEGACY = 7; - - // QUERY_NOT_SERVED_LEGACY means that a query could not be served right now. - // Client can interpret it as: "the tablet that you sent this query to cannot - // serve the query right now, try a different tablet or try again later." - // This could be due to various reasons: QueryService is not serving, should - // not be serving, wrong shard, wrong tablet type, table is part of the denylist, etc. - // Clients that receive this error should usually retry the query, but after taking - // the appropriate steps to make sure that the query will get sent to the correct - // tablet. - QUERY_NOT_SERVED_LEGACY = 8; - - // NOT_IN_TX_LEGACY means that we're not currently in a transaction, but we should be. - NOT_IN_TX_LEGACY = 9; - - // INTERNAL_ERROR_LEGACY means some invariants expected by underlying - // system has been broken. If you see one of these errors, - // something is very broken. - INTERNAL_ERROR_LEGACY = 10; - - // TRANSIENT_ERROR_LEGACY is used for when there is some error that we expect we can - // recover from automatically - often due to a resource limit temporarily being - // reached. Retrying this error, with an exponential backoff, should succeed. - // Clients should be able to successfully retry the query on the same backends. - // Examples of things that can trigger this error: - // 1. Query has been throttled - // 2. VtGate could have request backlog - TRANSIENT_ERROR_LEGACY = 11; - - // UNAUTHENTICATED_LEGACY errors are returned when a user requests access to something, - // and we're unable to verify the user's authentication. - UNAUTHENTICATED_LEGACY = 12; -} - // RPCError is an application-level error structure returned by // VtTablet (and passed along by VtGate if appropriate). // We use this so the clients don't have to parse the error messages, // but instead can depend on the value of the code. message RPCError { - LegacyErrorCode legacy_code = 1; + reserved 1; reserved "legacy_code"; string message = 2; Code code = 3; } diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index 39b9bf32ff7..bb5f573b8b5 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -23163,29 +23163,9 @@ export namespace vtrpc { DATA_LOSS = 15 } - /** LegacyErrorCode enum. */ - enum LegacyErrorCode { - SUCCESS_LEGACY = 0, - CANCELLED_LEGACY = 1, - UNKNOWN_ERROR_LEGACY = 2, - BAD_INPUT_LEGACY = 3, - DEADLINE_EXCEEDED_LEGACY = 4, - INTEGRITY_ERROR_LEGACY = 5, - PERMISSION_DENIED_LEGACY = 6, - RESOURCE_EXHAUSTED_LEGACY = 7, - QUERY_NOT_SERVED_LEGACY = 8, - NOT_IN_TX_LEGACY = 9, - INTERNAL_ERROR_LEGACY = 10, - TRANSIENT_ERROR_LEGACY = 11, - UNAUTHENTICATED_LEGACY = 12 - } - /** Properties of a RPCError. */ interface IRPCError { - /** RPCError legacy_code */ - legacy_code?: (vtrpc.LegacyErrorCode|null); - /** RPCError message */ message?: (string|null); @@ -23202,9 +23182,6 @@ export namespace vtrpc { */ constructor(properties?: vtrpc.IRPCError); - /** RPCError legacy_code. */ - public legacy_code: vtrpc.LegacyErrorCode; - /** RPCError message. */ public message: string; diff --git a/web/vtadmin/src/proto/vtadmin.js b/web/vtadmin/src/proto/vtadmin.js index 91f40ea745a..223151aece1 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -54640,49 +54640,12 @@ $root.vtrpc = (function() { return values; })(); - /** - * LegacyErrorCode enum. - * @name vtrpc.LegacyErrorCode - * @enum {number} - * @property {number} SUCCESS_LEGACY=0 SUCCESS_LEGACY value - * @property {number} CANCELLED_LEGACY=1 CANCELLED_LEGACY value - * @property {number} UNKNOWN_ERROR_LEGACY=2 UNKNOWN_ERROR_LEGACY value - * @property {number} BAD_INPUT_LEGACY=3 BAD_INPUT_LEGACY value - * @property {number} DEADLINE_EXCEEDED_LEGACY=4 DEADLINE_EXCEEDED_LEGACY value - * @property {number} INTEGRITY_ERROR_LEGACY=5 INTEGRITY_ERROR_LEGACY value - * @property {number} PERMISSION_DENIED_LEGACY=6 PERMISSION_DENIED_LEGACY value - * @property {number} RESOURCE_EXHAUSTED_LEGACY=7 RESOURCE_EXHAUSTED_LEGACY value - * @property {number} QUERY_NOT_SERVED_LEGACY=8 QUERY_NOT_SERVED_LEGACY value - * @property {number} NOT_IN_TX_LEGACY=9 NOT_IN_TX_LEGACY value - * @property {number} INTERNAL_ERROR_LEGACY=10 INTERNAL_ERROR_LEGACY value - * @property {number} TRANSIENT_ERROR_LEGACY=11 TRANSIENT_ERROR_LEGACY value - * @property {number} UNAUTHENTICATED_LEGACY=12 UNAUTHENTICATED_LEGACY value - */ - vtrpc.LegacyErrorCode = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "SUCCESS_LEGACY"] = 0; - values[valuesById[1] = "CANCELLED_LEGACY"] = 1; - values[valuesById[2] = "UNKNOWN_ERROR_LEGACY"] = 2; - values[valuesById[3] = "BAD_INPUT_LEGACY"] = 3; - values[valuesById[4] = "DEADLINE_EXCEEDED_LEGACY"] = 4; - values[valuesById[5] = "INTEGRITY_ERROR_LEGACY"] = 5; - values[valuesById[6] = "PERMISSION_DENIED_LEGACY"] = 6; - values[valuesById[7] = "RESOURCE_EXHAUSTED_LEGACY"] = 7; - values[valuesById[8] = "QUERY_NOT_SERVED_LEGACY"] = 8; - values[valuesById[9] = "NOT_IN_TX_LEGACY"] = 9; - values[valuesById[10] = "INTERNAL_ERROR_LEGACY"] = 10; - values[valuesById[11] = "TRANSIENT_ERROR_LEGACY"] = 11; - values[valuesById[12] = "UNAUTHENTICATED_LEGACY"] = 12; - return values; - })(); - vtrpc.RPCError = (function() { /** * Properties of a RPCError. * @memberof vtrpc * @interface IRPCError - * @property {vtrpc.LegacyErrorCode|null} [legacy_code] RPCError legacy_code * @property {string|null} [message] RPCError message * @property {vtrpc.Code|null} [code] RPCError code */ @@ -54702,14 +54665,6 @@ $root.vtrpc = (function() { this[keys[i]] = properties[keys[i]]; } - /** - * RPCError legacy_code. - * @member {vtrpc.LegacyErrorCode} legacy_code - * @memberof vtrpc.RPCError - * @instance - */ - RPCError.prototype.legacy_code = 0; - /** * RPCError message. * @member {string} message @@ -54750,8 +54705,6 @@ $root.vtrpc = (function() { RPCError.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.legacy_code != null && Object.hasOwnProperty.call(message, "legacy_code")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.legacy_code); if (message.message != null && Object.hasOwnProperty.call(message, "message")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.message); if (message.code != null && Object.hasOwnProperty.call(message, "code")) @@ -54790,9 +54743,6 @@ $root.vtrpc = (function() { while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.legacy_code = reader.int32(); - break; case 2: message.message = reader.string(); break; @@ -54834,25 +54784,6 @@ $root.vtrpc = (function() { RPCError.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.legacy_code != null && message.hasOwnProperty("legacy_code")) - switch (message.legacy_code) { - default: - return "legacy_code: enum value expected"; - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - break; - } if (message.message != null && message.hasOwnProperty("message")) if (!$util.isString(message.message)) return "message: string expected"; @@ -54894,60 +54825,6 @@ $root.vtrpc = (function() { if (object instanceof $root.vtrpc.RPCError) return object; var message = new $root.vtrpc.RPCError(); - switch (object.legacy_code) { - case "SUCCESS_LEGACY": - case 0: - message.legacy_code = 0; - break; - case "CANCELLED_LEGACY": - case 1: - message.legacy_code = 1; - break; - case "UNKNOWN_ERROR_LEGACY": - case 2: - message.legacy_code = 2; - break; - case "BAD_INPUT_LEGACY": - case 3: - message.legacy_code = 3; - break; - case "DEADLINE_EXCEEDED_LEGACY": - case 4: - message.legacy_code = 4; - break; - case "INTEGRITY_ERROR_LEGACY": - case 5: - message.legacy_code = 5; - break; - case "PERMISSION_DENIED_LEGACY": - case 6: - message.legacy_code = 6; - break; - case "RESOURCE_EXHAUSTED_LEGACY": - case 7: - message.legacy_code = 7; - break; - case "QUERY_NOT_SERVED_LEGACY": - case 8: - message.legacy_code = 8; - break; - case "NOT_IN_TX_LEGACY": - case 9: - message.legacy_code = 9; - break; - case "INTERNAL_ERROR_LEGACY": - case 10: - message.legacy_code = 10; - break; - case "TRANSIENT_ERROR_LEGACY": - case 11: - message.legacy_code = 11; - break; - case "UNAUTHENTICATED_LEGACY": - case 12: - message.legacy_code = 12; - break; - } if (object.message != null) message.message = String(object.message); switch (object.code) { @@ -55037,12 +54914,9 @@ $root.vtrpc = (function() { options = {}; var object = {}; if (options.defaults) { - object.legacy_code = options.enums === String ? "SUCCESS_LEGACY" : 0; object.message = ""; object.code = options.enums === String ? "OK" : 0; } - if (message.legacy_code != null && message.hasOwnProperty("legacy_code")) - object.legacy_code = options.enums === String ? $root.vtrpc.LegacyErrorCode[message.legacy_code] : message.legacy_code; if (message.message != null && message.hasOwnProperty("message")) object.message = message.message; if (message.code != null && message.hasOwnProperty("code")) From 52e35bbf7d1b5bc59ee5a558a723cc9cea858e1e Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Tue, 20 Jul 2021 15:41:19 -0400 Subject: [PATCH 2/3] Regenerate protos after rebase Signed-off-by: Andrew Mason --- web/vtadmin/src/proto/vtadmin.d.ts | 96 +++++++++++++ web/vtadmin/src/proto/vtadmin.js | 210 +++++++++++++++++++++++++++++ 2 files changed, 306 insertions(+) diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index bb5f573b8b5..eed15551a24 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -23616,6 +23616,102 @@ export namespace replicationdata { */ public toJSON(): { [k: string]: any }; } + + /** Properties of a PrimaryStatus. */ + interface IPrimaryStatus { + + /** PrimaryStatus position */ + position?: (string|null); + + /** PrimaryStatus file_position */ + file_position?: (string|null); + } + + /** Represents a PrimaryStatus. */ + class PrimaryStatus implements IPrimaryStatus { + + /** + * Constructs a new PrimaryStatus. + * @param [properties] Properties to set + */ + constructor(properties?: replicationdata.IPrimaryStatus); + + /** PrimaryStatus position. */ + public position: string; + + /** PrimaryStatus file_position. */ + public file_position: string; + + /** + * Creates a new PrimaryStatus instance using the specified properties. + * @param [properties] Properties to set + * @returns PrimaryStatus instance + */ + public static create(properties?: replicationdata.IPrimaryStatus): replicationdata.PrimaryStatus; + + /** + * Encodes the specified PrimaryStatus message. Does not implicitly {@link replicationdata.PrimaryStatus.verify|verify} messages. + * @param message PrimaryStatus message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: replicationdata.IPrimaryStatus, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PrimaryStatus message, length delimited. Does not implicitly {@link replicationdata.PrimaryStatus.verify|verify} messages. + * @param message PrimaryStatus message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: replicationdata.IPrimaryStatus, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PrimaryStatus message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PrimaryStatus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): replicationdata.PrimaryStatus; + + /** + * Decodes a PrimaryStatus message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PrimaryStatus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): replicationdata.PrimaryStatus; + + /** + * Verifies a PrimaryStatus message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PrimaryStatus message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PrimaryStatus + */ + public static fromObject(object: { [k: string]: any }): replicationdata.PrimaryStatus; + + /** + * Creates a plain object from a PrimaryStatus message. Also converts values to other types if specified. + * @param message PrimaryStatus + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: replicationdata.PrimaryStatus, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PrimaryStatus to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } } /** Namespace logutil. */ diff --git a/web/vtadmin/src/proto/vtadmin.js b/web/vtadmin/src/proto/vtadmin.js index 223151aece1..f971bd6548b 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -55824,6 +55824,216 @@ $root.replicationdata = (function() { return PrimaryStatus; })(); + replicationdata.PrimaryStatus = (function() { + + /** + * Properties of a PrimaryStatus. + * @memberof replicationdata + * @interface IPrimaryStatus + * @property {string|null} [position] PrimaryStatus position + * @property {string|null} [file_position] PrimaryStatus file_position + */ + + /** + * Constructs a new PrimaryStatus. + * @memberof replicationdata + * @classdesc Represents a PrimaryStatus. + * @implements IPrimaryStatus + * @constructor + * @param {replicationdata.IPrimaryStatus=} [properties] Properties to set + */ + function PrimaryStatus(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PrimaryStatus position. + * @member {string} position + * @memberof replicationdata.PrimaryStatus + * @instance + */ + PrimaryStatus.prototype.position = ""; + + /** + * PrimaryStatus file_position. + * @member {string} file_position + * @memberof replicationdata.PrimaryStatus + * @instance + */ + PrimaryStatus.prototype.file_position = ""; + + /** + * Creates a new PrimaryStatus instance using the specified properties. + * @function create + * @memberof replicationdata.PrimaryStatus + * @static + * @param {replicationdata.IPrimaryStatus=} [properties] Properties to set + * @returns {replicationdata.PrimaryStatus} PrimaryStatus instance + */ + PrimaryStatus.create = function create(properties) { + return new PrimaryStatus(properties); + }; + + /** + * Encodes the specified PrimaryStatus message. Does not implicitly {@link replicationdata.PrimaryStatus.verify|verify} messages. + * @function encode + * @memberof replicationdata.PrimaryStatus + * @static + * @param {replicationdata.IPrimaryStatus} message PrimaryStatus message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PrimaryStatus.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.position != null && Object.hasOwnProperty.call(message, "position")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.position); + if (message.file_position != null && Object.hasOwnProperty.call(message, "file_position")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.file_position); + return writer; + }; + + /** + * Encodes the specified PrimaryStatus message, length delimited. Does not implicitly {@link replicationdata.PrimaryStatus.verify|verify} messages. + * @function encodeDelimited + * @memberof replicationdata.PrimaryStatus + * @static + * @param {replicationdata.IPrimaryStatus} message PrimaryStatus message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PrimaryStatus.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PrimaryStatus message from the specified reader or buffer. + * @function decode + * @memberof replicationdata.PrimaryStatus + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {replicationdata.PrimaryStatus} PrimaryStatus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PrimaryStatus.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.replicationdata.PrimaryStatus(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.position = reader.string(); + break; + case 2: + message.file_position = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PrimaryStatus message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof replicationdata.PrimaryStatus + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {replicationdata.PrimaryStatus} PrimaryStatus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PrimaryStatus.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PrimaryStatus message. + * @function verify + * @memberof replicationdata.PrimaryStatus + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PrimaryStatus.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.position != null && message.hasOwnProperty("position")) + if (!$util.isString(message.position)) + return "position: string expected"; + if (message.file_position != null && message.hasOwnProperty("file_position")) + if (!$util.isString(message.file_position)) + return "file_position: string expected"; + return null; + }; + + /** + * Creates a PrimaryStatus message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof replicationdata.PrimaryStatus + * @static + * @param {Object.} object Plain object + * @returns {replicationdata.PrimaryStatus} PrimaryStatus + */ + PrimaryStatus.fromObject = function fromObject(object) { + if (object instanceof $root.replicationdata.PrimaryStatus) + return object; + var message = new $root.replicationdata.PrimaryStatus(); + if (object.position != null) + message.position = String(object.position); + if (object.file_position != null) + message.file_position = String(object.file_position); + return message; + }; + + /** + * Creates a plain object from a PrimaryStatus message. Also converts values to other types if specified. + * @function toObject + * @memberof replicationdata.PrimaryStatus + * @static + * @param {replicationdata.PrimaryStatus} message PrimaryStatus + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PrimaryStatus.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.position = ""; + object.file_position = ""; + } + if (message.position != null && message.hasOwnProperty("position")) + object.position = message.position; + if (message.file_position != null && message.hasOwnProperty("file_position")) + object.file_position = message.file_position; + return object; + }; + + /** + * Converts this PrimaryStatus to JSON. + * @function toJSON + * @memberof replicationdata.PrimaryStatus + * @instance + * @returns {Object.} JSON object + */ + PrimaryStatus.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return PrimaryStatus; + })(); + return replicationdata; })(); From e2a37bc0cb4c0b14d883b6f16e22f3367f806981 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Tue, 17 Aug 2021 15:16:12 -0400 Subject: [PATCH 3/3] Remove switch case for legacy error code in java client Signed-off-by: Andrew Mason --- .../src/main/java/io/vitess/client/Proto.java | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/java/client/src/main/java/io/vitess/client/Proto.java b/java/client/src/main/java/io/vitess/client/Proto.java index 1564a80a06d..3ab115756cd 100644 --- a/java/client/src/main/java/io/vitess/client/Proto.java +++ b/java/client/src/main/java/io/vitess/client/Proto.java @@ -92,26 +92,6 @@ public static void checkError(RPCError error) throws SQLException { throw new SQLNonTransientException("Vitess RPC error: " + error.toString(), sqlState, errno); } - - switch (error.getLegacyCode()) { - case SUCCESS_LEGACY: - break; - case BAD_INPUT_LEGACY: - throw new SQLSyntaxErrorException(error.toString(), sqlState, errno); - case DEADLINE_EXCEEDED_LEGACY: - throw new SQLTimeoutException(error.toString(), sqlState, errno); - case INTEGRITY_ERROR_LEGACY: - throw new SQLIntegrityConstraintViolationException(error.toString(), sqlState, errno); - case TRANSIENT_ERROR_LEGACY: - throw new SQLTransientException(error.toString(), sqlState, errno); - case UNAUTHENTICATED_LEGACY: - throw new SQLInvalidAuthorizationSpecException(error.toString(), sqlState, errno); - case NOT_IN_TX_LEGACY: - throw new SQLRecoverableException(error.toString(), sqlState, errno); - default: - throw new SQLNonTransientException("Vitess RPC error: " + error.toString(), sqlState, - errno); - } } }