-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Open
Labels
component/statisticssig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
func TestAutoAnalyzeAfterAnalyzeVersionChange(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)
tk := testkit.NewTestKit(t, store)
h := dom.StatsHandle()
// Trigger the sync load by query.
// set lease > 0 to trigger on-demand stats load.
h.SetLease(time.Millisecond)
// Set analyze version to 1.
tk.MustExec("set @@tidb_analyze_version = 1")
tk.MustExec("use test")
tk.MustExec("create table t (a int, b int, index idx(a));")
tk.MustExec("insert into t values (1, 2);")
tk.MustExec("analyze table t")
tbl, err := dom.InfoSchema().TableByName(context.Background(), ast.NewCIStr("test"), ast.NewCIStr("t"))
require.NoError(t, err)
tableInfo := tbl.Meta()
statsTbl := h.GetPhysicalTableStats(tableInfo.ID, tableInfo)
require.NotZero(t, statsTbl.LastAnalyzeVersion)
require.Equal(t, 0, statsTbl.StatsVer)
}2. What did you expect to see? (Required)
The stats version is 1.
3. What did you see instead (Required)
The stats version is 0.
4. What is your TiDB version? (Required)
master
Metadata
Metadata
Assignees
Labels
component/statisticssig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.