From 8b970d7d41f6d680036304feea22ac72de7cd094 Mon Sep 17 00:00:00 2001 From: HuaiyuXu <391585975@qq.com> Date: Wed, 26 Dec 2018 11:00:06 +0800 Subject: [PATCH] planner: fix a sporadic panic due to the PR #7684 when using the prepared plan cache (#7956) (#8826) --- executor/prepared.go | 4 ++++ tidb-server/main.go | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/executor/prepared.go b/executor/prepared.go index bb886b9f26721..4cd28f1c7679d 100644 --- a/executor/prepared.go +++ b/executor/prepared.go @@ -128,6 +128,10 @@ func (e *PrepareExec) Next(ctx context.Context, chk *chunk.Chunk) error { if _, ok := stmt.(ast.DDLNode); ok { return ErrPrepareDDL } + err = ResetContextOfStmt(e.ctx, stmt) + if err != nil { + return err + } var extractor paramMarkerExtractor stmt.Accept(&extractor) diff --git a/tidb-server/main.go b/tidb-server/main.go index c03a10ad6fe72..02fe72c9740f2 100644 --- a/tidb-server/main.go +++ b/tidb-server/main.go @@ -405,7 +405,8 @@ func setGlobalVars() { variable.SysVars[variable.TIDBMemQuotaQuery].Value = strconv.FormatInt(cfg.MemQuotaQuery, 10) variable.SysVars["lower_case_table_names"].Value = strconv.Itoa(cfg.LowerCaseTableNames) - plannercore.SetPreparedPlanCache(cfg.PreparedPlanCache.Enabled) + // For CI environment we default enable prepare-plan-cache. + plannercore.SetPreparedPlanCache(config.CheckTableBeforeDrop || cfg.PreparedPlanCache.Enabled) if plannercore.PreparedPlanCacheEnabled() { plannercore.PreparedPlanCacheCapacity = cfg.PreparedPlanCache.Capacity }