From 0937d3752803d210a7776e4002829bbe3f3b3d0f Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Wed, 31 Jul 2024 19:47:50 +0800 Subject: [PATCH] planner: fix DATA RACE caused by initializing PointGet stats (#53676) (#55034) close pingcap/tidb#43339 --- pkg/planner/core/point_get_plan.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/planner/core/point_get_plan.go b/pkg/planner/core/point_get_plan.go index 0a378b3fd559e..965ec92c9ee8a 100644 --- a/pkg/planner/core/point_get_plan.go +++ b/pkg/planner/core/point_get_plan.go @@ -228,9 +228,8 @@ func (*PointGetPlan) StatsCount() float64 { // StatsInfo will return the RowCount of property.StatsInfo for this plan. func (p *PointGetPlan) StatsInfo() *property.StatsInfo { if p.Plan.StatsInfo() == nil { - p.Plan.SetStats(&property.StatsInfo{}) + p.Plan.SetStats(&property.StatsInfo{RowCount: 1}) } - p.Plan.StatsInfo().RowCount = 1 return p.Plan.StatsInfo() } @@ -1485,6 +1484,7 @@ func newPointGetPlan(ctx PlanContext, dbName string, schema *expression.Schema, outputNames: names, LockWaitTime: ctx.GetSessionVars().LockWaitTimeout, } + p.Plan.SetStats(&property.StatsInfo{RowCount: 1}) ctx.GetSessionVars().StmtCtx.Tables = []stmtctx.TableEntry{{DB: dbName, Table: tbl.Name.L}} return p }