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

*: skip log timeout on maxExecutiontime as slow query for DDL statement. #38671

Merged
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: 5 additions & 1 deletion executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,14 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) {
}
maxExecutionTime := getMaxExecutionTime(sctx)
// Update processinfo, ShowProcess() will use it.
pi.SetProcessInfo(sql, time.Now(), cmd, maxExecutionTime)
if a.Ctx.GetSessionVars().StmtCtx.StmtType == "" {
a.Ctx.GetSessionVars().StmtCtx.StmtType = ast.GetStmtLabel(a.StmtNode)
}
// Since maxExecutionTime is used only for query statement, here we limit it affect scope.
Benjamin2037 marked this conversation as resolved.
Show resolved Hide resolved
if !a.IsReadOnly(a.Ctx.GetSessionVars()) {
maxExecutionTime = 0
}
pi.SetProcessInfo(sql, time.Now(), cmd, maxExecutionTime)
}

failpoint.Inject("mockDelayInnerSessionExecute", func() {
Expand Down
5 changes: 5 additions & 0 deletions server/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,11 @@ func TestConnExecutionTimeout(t *testing.T) {

err = cc.handleQuery(context.Background(), "select /*+ MAX_EXECUTION_TIME(100)*/ * FROM testTable2 WHERE SLEEP(1);")
require.NoError(t, err)

tk.MustExec("set @@max_execution_time = 500;")

err = cc.handleQuery(context.Background(), "alter table testTable2 add index idx(age);")
require.NoError(t, err)
}

func TestShutDown(t *testing.T) {
Expand Down