Skip to content

Commit

Permalink
Merge pull request #1331 from alainjobart/resharding
Browse files Browse the repository at this point in the history
Retiring deprecated vtgate/proto.QueryResult.Error.
  • Loading branch information
alainjobart committed Nov 18, 2015
2 parents a42c2c8 + 5d7ded7 commit a2dd404
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 33 deletions.
3 changes: 0 additions & 3 deletions go/cmd/vtgateclienttest/services/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func requestToPartialError(request string, session *vtgatepb.Session, reply *pro
parts := strings.Split(request, "/")
rpcErr := vterrors.RPCErrFromVtError(trimmedRequestToError(parts[0]))
reply.Err = rpcErr
reply.Error = rpcErr.Message
reply.Session = session
if len(parts) > 1 && parts[1] == "close transaction" {
reply.Session.InTransaction = false
Expand Down Expand Up @@ -175,7 +174,6 @@ func (c *errorClient) ExecuteBatchShards(ctx context.Context, queries []*vtgatep
var partialReply proto.QueryResult
if requestToPartialError(queries[0].Query.Sql, session, &partialReply) {
reply.Err = partialReply.Err
reply.Error = partialReply.Error
reply.Session = partialReply.Session
return nil
}
Expand All @@ -191,7 +189,6 @@ func (c *errorClient) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vt
var partialReply proto.QueryResult
if requestToPartialError(queries[0].Query.Sql, session, &partialReply) {
reply.Err = partialReply.Err
reply.Error = partialReply.Error
reply.Session = partialReply.Session
return nil
}
Expand Down
5 changes: 0 additions & 5 deletions go/vt/client/fakeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ func (f *fakeVTGateService) StreamExecute(ctx context.Context, sql string, bindV
}
}
}
if execCase.reply.Error != "" {
return errors.New(execCase.reply.Error)
}
return nil
}

Expand Down Expand Up @@ -195,7 +192,6 @@ var execMap = map[string]struct {
reply: &proto.QueryResult{
Result: &result1,
Session: nil,
Error: "",
},
},
"txRequest": {
Expand All @@ -220,7 +216,6 @@ var execMap = map[string]struct {
reply: &proto.QueryResult{
Result: &sqltypes.Result{},
Session: session2,
Error: "",
},
},
}
Expand Down
10 changes: 2 additions & 8 deletions go/vt/vtgate/proto/vtgate_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ type EntityIdsQuery struct {
type QueryResult struct {
Result *sqltypes.Result
Session *pb.Session
// Error field is deprecated, as it only returns a string. New users should use the
// Err field below, which contains a string and an error code.
Error string
Err *mproto.RPCError
Err *mproto.RPCError
}

// BoundShardQuery represents a single query request for the
Expand Down Expand Up @@ -133,10 +130,7 @@ type KeyspaceIdBatchQuery struct {
type QueryResultList struct {
List []sqltypes.Result
Session *pb.Session
// Error field is deprecated, as it only returns a string. New users should use the
// Err field below, which contains a string and an error code.
Error string
Err *mproto.RPCError
Err *mproto.RPCError
}

// SplitQueryRequest is a request to split a query into multiple parts
Expand Down
17 changes: 8 additions & 9 deletions go/vt/vtgate/vtgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (vtg *VTGate) Execute(ctx context.Context, sql string, bindVariables map[st
"Session": session,
"NotInTransaction": notInTransaction,
}
reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecute).Error()
handleExecuteError(err, statsKey, query, vtg.logExecute)
reply.Err = vterrors.RPCErrFromVtError(err)
}
reply.Session = session
Expand Down Expand Up @@ -226,7 +226,7 @@ func (vtg *VTGate) ExecuteShards(ctx context.Context, sql string, bindVariables
"Session": session,
"NotInTransaction": notInTransaction,
}
reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteShards).Error()
handleExecuteError(err, statsKey, query, vtg.logExecuteShards)
reply.Err = vterrors.RPCErrFromVtError(err)
}
reply.Session = session
Expand Down Expand Up @@ -261,7 +261,7 @@ func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, sql string, bindVaria
"Session": session,
"NotInTransaction": notInTransaction,
}
reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteKeyspaceIds).Error()
handleExecuteError(err, statsKey, query, vtg.logExecuteKeyspaceIds)
reply.Err = vterrors.RPCErrFromVtError(err)
}
reply.Session = session
Expand Down Expand Up @@ -296,7 +296,7 @@ func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, sql string, bindVariabl
"Session": session,
"NotInTransaction": notInTransaction,
}
reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteKeyRanges).Error()
handleExecuteError(err, statsKey, query, vtg.logExecuteKeyRanges)
reply.Err = vterrors.RPCErrFromVtError(err)
}
reply.Session = session
Expand Down Expand Up @@ -332,7 +332,7 @@ func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, sql string, bindVariabl
"Session": session,
"NotInTransaction": notInTransaction,
}
reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteEntityIds).Error()
handleExecuteError(err, statsKey, query, vtg.logExecuteEntityIds)
reply.Err = vterrors.RPCErrFromVtError(err)
}
reply.Session = session
Expand Down Expand Up @@ -375,7 +375,7 @@ func (vtg *VTGate) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.B
"AsTransaction": asTransaction,
"Session": session,
}
reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteBatchShards).Error()
handleExecuteError(err, statsKey, query, vtg.logExecuteBatchShards)
reply.Err = vterrors.RPCErrFromVtError(err)
}
reply.Session = session
Expand Down Expand Up @@ -416,7 +416,7 @@ func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgat
"AsTransaction": asTransaction,
"Session": session,
}
reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteBatchKeyspaceIds).Error()
handleExecuteError(err, statsKey, query, vtg.logExecuteBatchKeyspaceIds)
reply.Err = vterrors.RPCErrFromVtError(err)
}
reply.Session = session
Expand Down Expand Up @@ -709,7 +709,7 @@ func isErrorCausedByVTGate(err error) bool {
return false
}

func handleExecuteError(err error, statsKey []string, query map[string]interface{}, logger *logutil.ThrottledLogger) error {
func handleExecuteError(err error, statsKey []string, query map[string]interface{}, logger *logutil.ThrottledLogger) {
s := fmt.Sprintf(", vtgate: %v", servenv.ListeningURL.String())
newErr := vterrors.WithSuffix(err, s)
errStr := newErr.Error()
Expand All @@ -723,7 +723,6 @@ func handleExecuteError(err error, statsKey []string, query map[string]interface
normalErrors.Add(statsKey, 1)
logError(err, query, logger)
}
return newErr
}

func formatError(err error) error {
Expand Down
10 changes: 2 additions & 8 deletions go/vt/vtgate/vtgateconntest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,8 @@ func (f *fakeVTGateService) ExecuteBatchShards(ctx context.Context, queries []*v
f.t.Errorf("ExecuteBatchShards: %+v, want %+v", query, execCase.batchQueryShard)
return nil
}
reply.Error = execCase.reply.Error
reply.Err = execCase.reply.Err
if reply.Error == "" && execCase.reply.Result != nil {
if execCase.reply.Result != nil {
reply.List = []sqltypes.Result{*execCase.reply.Result}
}
reply.Session = execCase.reply.Session
Expand Down Expand Up @@ -351,9 +350,8 @@ func (f *fakeVTGateService) ExecuteBatchKeyspaceIds(ctx context.Context, queries
f.t.Errorf("ExecuteBatchKeyspaceIds: %+v, want %+v", query, execCase.keyspaceIDBatchQuery)
return nil
}
reply.Error = execCase.reply.Error
reply.Err = execCase.reply.Err
if reply.Error == "" && execCase.reply.Result != nil {
if execCase.reply.Result != nil {
reply.List = []sqltypes.Result{*execCase.reply.Result}
}
reply.Session = execCase.reply.Session
Expand Down Expand Up @@ -2387,7 +2385,6 @@ var execMap = map[string]struct {
reply: &proto.QueryResult{
Result: &result1,
Session: nil,
Error: "",
},
},
"errorRequst": {
Expand Down Expand Up @@ -2498,7 +2495,6 @@ var execMap = map[string]struct {
reply: &proto.QueryResult{
Result: nil,
Session: nil,
Error: executePartialErrString,
Err: &mproto.RPCError{
Code: int64(expectedCode),
Message: executePartialErrString,
Expand Down Expand Up @@ -2613,7 +2609,6 @@ var execMap = map[string]struct {
reply: &proto.QueryResult{
Result: nil,
Session: session2,
Error: "",
},
},
"txRequestNIT": {
Expand Down Expand Up @@ -2729,7 +2724,6 @@ var execMap = map[string]struct {
reply: &proto.QueryResult{
Result: nil,
Session: session1,
Error: "",
},
},
}
Expand Down

0 comments on commit a2dd404

Please sign in to comment.