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

Add a test to verify we respect the overall query timeout #16800

Merged
merged 1 commit into from
Sep 18, 2024
Merged
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
27 changes: 27 additions & 0 deletions go/test/endtoend/vtgate/queries/timeout/timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,30 @@ func TestQueryTimeoutWithoutVTGateDefault(t *testing.T) {
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select sleep(5) from dual")
assert.Error(t, err)
}

// TestOverallQueryTimeout tests that the query timeout is applied to the overall execution of a query
// and not just individual routes.
func TestOverallQueryTimeout(t *testing.T) {
utils.SkipIfBinaryIsBelowVersion(t, 21, "vtgate")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we changed our downgrade tests, I don't think we need to include the skip if binary is below version command.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would still need this. For upgrade tests running in a PR against release-20.0, we would end up using the code in main (upgrade target) to run the tests with both vtgate N+1, vttablet N and vtgate N, vttablet N+1. For the latter case we don't want to run this test. So, we need this skip line.

mcmp, closer := start(t)
defer closer()

mcmp.Exec("insert into t1(id1, id2) values (2,2),(3,3)")

// After inserting the rows above, if we run the following query, we will end up doing join on vtgate
// that issues one select query on the left side and 2 on the right side. The queries on the right side
// take 2 and 3 seconds each to run. If we have an overall timeout for 4 seconds, then it should fail.
_, err := utils.ExecAllowError(t, mcmp.VtConn, "select /*vt+ QUERY_TIMEOUT_MS=4000 */ sleep(u2.id2), u1.id2 from t1 u1 join t1 u2 where u1.id2 = u2.id1")
assert.Error(t, err)
assert.ErrorContains(t, err, "DeadlineExceeded desc = context deadline exceeded (errno 1317) (sqlstate 70100)")

// Let's also check that setting the session variable also works.
utils.Exec(t, mcmp.VtConn, "set query_timeout=4000")
_, err = utils.ExecAllowError(t, mcmp.VtConn, "select sleep(u2.id2), u1.id2 from t1 u1 join t1 u2 where u1.id2 = u2.id1")
assert.Error(t, err)
assert.ErrorContains(t, err, "DeadlineExceeded desc = context deadline exceeded (errno 1317) (sqlstate 70100)")

// Increasing the timeout should pass the query.
utils.Exec(t, mcmp.VtConn, "set query_timeout=10000")
_ = utils.Exec(t, mcmp.VtConn, "select sleep(u2.id2), u1.id2 from t1 u1 join t1 u2 where u1.id2 = u2.id1")
}
Loading