From bf9d68ba8b5c638f7330cfeaa1cefb8a5dec2eba Mon Sep 17 00:00:00 2001 From: gouhongshen Date: Thu, 22 Jan 2026 13:23:30 +0800 Subject: [PATCH] set timeout for clean tempTable --- pkg/frontend/server.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/frontend/server.go b/pkg/frontend/server.go index dea5049d82287..a7a3f696c63d5 100644 --- a/pkg/frontend/server.go +++ b/pkg/frontend/server.go @@ -195,10 +195,21 @@ func (mo *MOServer) cleanOrphanTempTables() error { if mo.rm == nil || mo.rm.sessionManager == nil { return nil } - ctx := mo.rm.ctx + + var ( + ctx = mo.rm.ctx + cancel context.CancelFunc + ) + if ctx == nil { return nil } + + ctx, cancel = context.WithTimeoutCause(ctx, time.Second*60, context.DeadlineExceeded) + defer func() { + cancel() + }() + if _, ok := moruntime.ServiceRuntime(mo.service).GetGlobalVariables(moruntime.InternalSQLExecutor); !ok { logutil.Warn("temp-table-cleanup: internal sql executor not ready") return nil