Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misleading error mapping for row limit error #9448

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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