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 TestQueryTimeoutWithTables flaky test #13579

Merged
merged 1 commit into from
Jul 21, 2023
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
6 changes: 4 additions & 2 deletions go/test/endtoend/vtgate/queries/misc/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ func TestMain(m *testing.M) {
return 1
}

clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, "--queryserver-config-max-result-size", "1000000",
clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs,
"--queryserver-config-max-result-size", "1000000",
"--queryserver-config-query-timeout", "200",
"--queryserver-config-query-pool-timeout", "200")
// Start Unsharded keyspace
Expand All @@ -85,7 +86,8 @@ func TestMain(m *testing.M) {
return 1
}

clusterInstance.VtGateExtraArgs = append(clusterInstance.VtGateExtraArgs, "--enable_system_settings=true", "--query-timeout=100")
clusterInstance.VtGateExtraArgs = append(clusterInstance.VtGateExtraArgs,
"--query-timeout", "100")
// Start vtgate
err = clusterInstance.StartVtgate()
if err != nil {
Expand Down
43 changes: 13 additions & 30 deletions go/test/endtoend/vtgate/queries/misc/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@ func TestQueryTimeoutWithDual(t *testing.T) {
mcmp, closer := start(t)
defer closer()

_, err := utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 */ sleep(0.04) from dual")
_, err := utils.ExecAllowError(t, mcmp.VtConn, "select sleep(0.04) from dual")
assert.NoError(t, err)
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 */ sleep(0.24) from dual")
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select sleep(0.24) from dual")
assert.Error(t, err)
_, err = utils.ExecAllowError(t, mcmp.VtConn, "set @@session.query_timeout=20")
require.NoError(t, err)
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 */ sleep(0.04) from dual")
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select sleep(0.04) from dual")
assert.Error(t, err)
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 */ sleep(0.01) from dual")
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select sleep(0.01) from dual")
assert.NoError(t, err)
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 QUERY_TIMEOUT_MS=500 */ sleep(0.24) from dual")
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ QUERY_TIMEOUT_MS=500 */ sleep(0.24) from dual")
assert.NoError(t, err)
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 QUERY_TIMEOUT_MS=10 */ sleep(0.04) from dual")
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ QUERY_TIMEOUT_MS=10 */ sleep(0.04) from dual")
assert.Error(t, err)
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 QUERY_TIMEOUT_MS=15 */ sleep(0.001) from dual")
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ QUERY_TIMEOUT_MS=15 */ sleep(0.001) from dual")
assert.NoError(t, err)
}

Expand All @@ -129,37 +129,20 @@ func TestQueryTimeoutWithTables(t *testing.T) {
}

utils.Exec(t, mcmp.VtConn, "select count(*) from uks.unsharded where id1 > 31")
utils.Exec(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 QUERY_TIMEOUT_MS=100 */ count(*) from uks.unsharded where id1 > 31")
utils.Exec(t, mcmp.VtConn, "select /*vt+ QUERY_TIMEOUT_MS=100 */ count(*) from uks.unsharded where id1 > 31")

// the query usually takes more than 5ms to return. So this should fail.
_, err := utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 QUERY_TIMEOUT_MS=1 */ count(*) from uks.unsharded where id1 > 31")
_, err := utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ QUERY_TIMEOUT_MS=1 */ count(*) from uks.unsharded where id1 > 31")
require.Error(t, err)
assert.Contains(t, err.Error(), "context deadline exceeded")
assert.Contains(t, err.Error(), "(errno 1317) (sqlstate 70100)")

// sharded
for i := 0; i < 300000; i += 1000 {
var str strings.Builder
for j := 1; j <= 1000; j++ {
if j == 1 {
str.WriteString(fmt.Sprintf("(%d)", i*1000+j))
continue
}
str.WriteString(fmt.Sprintf(",(%d)", i*1000+j))
}
utils.Exec(t, mcmp.VtConn, fmt.Sprintf("insert /*vt+ QUERY_TIMEOUT_MS=1000 */ into t1(id1) values %s", str.String()))
}
// too much data added in the loop, do drop and recreate the table.
defer func() {
mcmp.Exec("drop /*vt+ QUERY_TIMEOUT_MS=1000 */ table t1")
mcmp.Exec(schemaSQL)
}()
utils.Exec(t, mcmp.VtConn, "insert /*vt+ QUERY_TIMEOUT_MS=1000 */ into ks_misc.t1(id1, id2) values (1,2),(2,4),(3,6),(4,8),(5,10)")

utils.Exec(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 QUERY_TIMEOUT_MS=1000 */ count(*) from t1 where id1 > 31")
utils.Exec(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 QUERY_TIMEOUT_MS=1000 */ count(*) from t1 where id1 > 31")

// the query usually takes more than 5ms to return. So this should fail.
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ PLANNER=gen4 QUERY_TIMEOUT_MS=1 */ count(*) from t1 where id1 > 31")
// sleep take in seconds, so 0.1 is 100ms
utils.Exec(t, mcmp.VtConn, "select /*vt+ QUERY_TIMEOUT_MS=500 */ sleep(0.1) from t1 where id1 = 1")
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ QUERY_TIMEOUT_MS=20 */ sleep(0.1) from t1 where id1 = 1")
require.Error(t, err)
assert.Contains(t, err.Error(), "context deadline exceeded")
assert.Contains(t, err.Error(), "(errno 1317) (sqlstate 70100)")
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/vtgate/queries/misc/schema.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
create /*vt+ QUERY_TIMEOUT_MS=1000 */ table if not exists t1(
create table if not exists t1(
id1 bigint,
id2 bigint,
primary key(id1)
Expand Down
Loading