From d85ad8815842b67fc18b98abe632fe3cb5c86117 Mon Sep 17 00:00:00 2001 From: Jun-Seok Heo Date: Mon, 29 Oct 2018 20:05:04 +0900 Subject: [PATCH] planner: fix a sporadic panic due to the PR #7684 when using the prepared plan cache (#7956) --- 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 dc63db3a0fe1e..c583314475efe 100644 --- a/executor/prepared.go +++ b/executor/prepared.go @@ -124,6 +124,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 255b9fff0e29b..8760cd0237781 100644 --- a/tidb-server/main.go +++ b/tidb-server/main.go @@ -393,7 +393,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 }