Skip to content

Commit

Permalink
Merge pull request #9448 from planetscale/row-limit-error
Browse files Browse the repository at this point in the history
Fix misleading error mapping for row limit error
  • Loading branch information
GuptaManan100 authored Dec 30, 2021
2 parents be2ec70 + 650f544 commit 8bb0235
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion go/test/endtoend/vtgate/unsharded/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func TestMain(m *testing.M) {
SchemaSQL: SchemaSQL,
VSchema: VSchema,
}
clusterInstance.VtTabletExtraArgs = []string{"-queryserver-config-transaction-timeout", "3"}
clusterInstance.VtTabletExtraArgs = []string{"-queryserver-config-transaction-timeout", "3", "-queryserver-config-max-result-size", "30"}
if err := clusterInstance.StartUnshardedKeyspace(*Keyspace, 0, false); err != nil {
log.Fatal(err.Error())
return 1
Expand Down Expand Up @@ -463,6 +463,22 @@ func TestFloatValueDefault(t *testing.T) {
assertMatches(t, conn, "select table_name, column_name, column_default from information_schema.columns where table_name = 'test_float_default'", `[[VARCHAR("test_float_default") VARCHAR("pos_f") TEXT("2.1")] [VARCHAR("test_float_default") VARCHAR("neg_f") TEXT("-2.1")]]`)
}

// TestRowCountExceeded tests the error message received when a query exceeds the row count specified
func TestRowCountExceeded(t *testing.T) {
vtParams := mysql.ConnParams{
Host: "localhost",
Port: clusterInstance.VtgateMySQLPort,
}
conn, err := mysql.Connect(context.Background(), &vtParams)
require.NoError(t, err)
defer conn.Close()

defer exec(t, conn, `delete from t1`)
execMulti(t, conn, `insert into t1(c1, c2, c3, c4) values (300,100,300,'abc'), (301,101,301,'abcd'), (1,1,1,'a'), (31,11,31,'ad');`)

execAssertError(t, conn, "select * from t1, t1 t2, t1 t3", `Aborted desc = Row count exceeded 30 (errno 10001) (sqlstate HY000)`)
}

func exec(t *testing.T, conn *mysql.Conn, query string) *sqltypes.Result {
t.Helper()
qr, err := conn.ExecuteFetch(query, 1000, true)
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 @@ -1548,7 +1548,7 @@ func convertErrorCode(err error) vtrpcpb.Code {
case mysql.ERNotSupportedYet:
errCode = vtrpcpb.Code_UNIMPLEMENTED
case mysql.ERDiskFull, mysql.EROutOfMemory, mysql.EROutOfSortMemory, mysql.ERConCount, mysql.EROutOfResources, mysql.ERRecordFileFull, mysql.ERHostIsBlocked,
mysql.ERCantCreateThread, mysql.ERTooManyDelayedThreads, mysql.ERNetPacketTooLarge, mysql.ERTooManyUserConnections, mysql.ERLockTableFull, mysql.ERUserLimitReached, mysql.ERVitessMaxRowsExceeded:
mysql.ERCantCreateThread, mysql.ERTooManyDelayedThreads, mysql.ERNetPacketTooLarge, mysql.ERTooManyUserConnections, mysql.ERLockTableFull, mysql.ERUserLimitReached:
errCode = vtrpcpb.Code_RESOURCE_EXHAUSTED
case mysql.ERLockWaitTimeout:
errCode = vtrpcpb.Code_DEADLINE_EXCEEDED
Expand All @@ -1569,7 +1569,7 @@ func convertErrorCode(err error) vtrpcpb.Code {
errCode = vtrpcpb.Code_CLUSTER_EVENT
case mysql.ERTableExists, mysql.ERDupEntry, mysql.ERFileExists, mysql.ERUDFExists:
errCode = vtrpcpb.Code_ALREADY_EXISTS
case mysql.ERGotSignal, mysql.ERForcingClose, mysql.ERAbortingConnection, mysql.ERLockDeadlock:
case mysql.ERGotSignal, mysql.ERForcingClose, mysql.ERAbortingConnection, mysql.ERLockDeadlock, mysql.ERVitessMaxRowsExceeded:
// For ERLockDeadlock, a deadlock rolls back the transaction.
errCode = vtrpcpb.Code_ABORTED
case mysql.ERUnknownComError, mysql.ERBadNullError, mysql.ERBadDb, mysql.ERBadTable, mysql.ERNonUniq, mysql.ERWrongFieldWithGroup, mysql.ERWrongGroupField,
Expand Down

0 comments on commit 8bb0235

Please sign in to comment.