Skip to content

Commit

Permalink
Merge pull request #6012 from tinyspeck/improve-some-error-codes
Browse files Browse the repository at this point in the history
Improve error codes returned by tabletserver
  • Loading branch information
sougou authored Apr 6, 2020
2 parents affbb32 + 8cc5f43 commit 4134a82
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions go/mysql/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ const (
ERNoDefault = 1230
EROperandColumns = 1241
ERSubqueryNo1Row = 1242
ERWarnDataOutOfRange = 1264
ERNonUpdateableTable = 1288
ERFeatureDisabled = 1289
EROptionPreventsStatement = 1290
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vttablet/endtoend/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ func TestQueryTimeout(t *testing.T) {
return
}
_, err = client.Execute("select sleep(1) from vitess_test", nil)
if code := vterrors.Code(err); code != vtrpcpb.Code_DEADLINE_EXCEEDED {
t.Errorf("Error code: %v, want %v", code, vtrpcpb.Code_DEADLINE_EXCEEDED)
if code := vterrors.Code(err); code != vtrpcpb.Code_CANCELED {
t.Errorf("Error code: %v, want %v", code, vtrpcpb.Code_CANCELED)
}
_, err = client.Execute("select 1 from dual", nil)
if code := vterrors.Code(err); code != vtrpcpb.Code_ABORTED {
Expand Down Expand Up @@ -435,8 +435,8 @@ func TestQueryPoolTimeout(t *testing.T) {
framework.Server.QueryTimeout.Set(100 * time.Millisecond)

_, err = client.Execute("select sleep(1) from vitess_test", nil)
if code := vterrors.Code(err); code != vtrpcpb.Code_DEADLINE_EXCEEDED {
t.Errorf("Error code: %v, want %v", code, vtrpcpb.Code_DEADLINE_EXCEEDED)
if code := vterrors.Code(err); code != vtrpcpb.Code_CANCELED {
t.Errorf("Error code: %v, want %v", code, vtrpcpb.Code_CANCELED)
}

vend := framework.DebugVars()
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/endtoend/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ func TestStreamTerminate(t *testing.T) {
return nil
},
)
if code := vterrors.Code(err); code != vtrpcpb.Code_DEADLINE_EXCEEDED {
t.Errorf("Errorcode: %v, want %v", code, vtrpcpb.Code_DEADLINE_EXCEEDED)
if code := vterrors.Code(err); code != vtrpcpb.Code_CANCELED {
t.Errorf("Errorcode: %v, want %v", code, vtrpcpb.Code_CANCELED)
}
}

Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/tabletserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ func convertErrorCode(err error) vtrpcpb.Code {
mysql.ERTooLongString, mysql.ERDelayedInsertTableLocked, mysql.ERDupUnique, mysql.ERRequiresPrimaryKey, mysql.ERCantDoThisDuringAnTransaction, mysql.ERReadOnlyTransaction,
mysql.ERCannotAddForeign, mysql.ERNoReferencedRow, mysql.ERRowIsReferenced, mysql.ERCantUpdateWithReadLock, mysql.ERNoDefault, mysql.EROperandColumns,
mysql.ERSubqueryNo1Row, mysql.ERNonUpdateableTable, mysql.ERFeatureDisabled, mysql.ERDuplicatedValueInType, mysql.ERRowIsReferenced2,
mysql.ErNoReferencedRow2:
mysql.ErNoReferencedRow2, mysql.ERWarnDataOutOfRange:
errCode = vtrpcpb.Code_FAILED_PRECONDITION
case mysql.EROptionPreventsStatement:
// Special-case this error code. It's probably because
Expand Down Expand Up @@ -1607,7 +1607,7 @@ func convertErrorCode(err error) vtrpcpb.Code {
}
case mysql.CRServerLost:
// Query was killed.
errCode = vtrpcpb.Code_DEADLINE_EXCEEDED
errCode = vtrpcpb.Code_CANCELED
}

return errCode
Expand Down

0 comments on commit 4134a82

Please sign in to comment.