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 error message check on query timeout #16827

Merged
merged 1 commit into from
Sep 24, 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
10 changes: 8 additions & 2 deletions go/test/endtoend/vtgate/queries/timeout/timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package misc

import (
"context"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -194,13 +195,18 @@ func TestOverallQueryTimeout(t *testing.T) {
// 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)")
// We can get two different error messages based on whether it is coming from vttablet or vtgate
if !strings.Contains(err.Error(), "Query execution was interrupted, maximum statement execution time exceeded") {
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)")
if !strings.Contains(err.Error(), "Query execution was interrupted, maximum statement execution time exceeded") {
assert.ErrorContains(t, err, "DeadlineExceeded desc = context deadline exceeded (errno 1317) (sqlstate 70100)")
}
Comment on lines -197 to +209
Copy link
Member

@harshit-gangal harshit-gangal Sep 24, 2024

Choose a reason for hiding this comment

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

If you look at other test in the file.
we just check the deadline error and error code. which is same in both the error messages

TestQueryTimeoutWithTables:
assert.ErrorContains(t, err, "context deadline exceeded")
assert.ErrorContains(t, err, "(errno 1317) (sqlstate 70100)")


// Increasing the timeout should pass the query.
utils.Exec(t, mcmp.VtConn, "set query_timeout=10000")
Expand Down
Loading