diff --git a/domain/historical_stats.go b/domain/historical_stats.go index 599eff13799b9..5d6d90feedef8 100644 --- a/domain/historical_stats.go +++ b/domain/historical_stats.go @@ -68,6 +68,7 @@ func (w *HistoricalStatsWorker) DumpHistoricalStats(tableID int64, statsHandle * return errors.Errorf("cannot get DBInfo by TableID %d", tableID) } if _, err := statsHandle.RecordHistoricalStatsToStorage(dbInfo.Name.O, tblInfo, tableID, isPartition); err != nil { + generateHistoricalStatsFailedCounter.Inc() return errors.Errorf("record table %s.%s's historical stats failed, err:%v", dbInfo.Name.O, tblInfo.Name.O, err) } generateHistoricalStatsSuccessCounter.Inc() diff --git a/statistics/handle/handle_test.go b/statistics/handle/handle_test.go index eded5f771273d..ac9936bed11fe 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -1159,8 +1159,8 @@ func TestGlobalStatsData2(t *testing.T) { tk.MustExec("analyze table tint with 2 topn, 2 buckets") tk.MustQuery("select modify_count, count from mysql.stats_meta order by table_id asc").Check(testkit.Rows( - "0 20", // global: g.count = p0.count + p1.count - "0 9", // p0 + "0 20", // global: g.count = p0.count + p1.count + "0 9", // p0 "0 11")) // p1 tk.MustQuery("show stats_topn where table_name='tint' and is_index=0").Check(testkit.Rows( @@ -1190,7 +1190,7 @@ func TestGlobalStatsData2(t *testing.T) { tk.MustQuery("select distinct_count, null_count, tot_col_size from mysql.stats_histograms where is_index=0 order by table_id asc").Check( testkit.Rows("12 1 19", // global, g = p0 + p1 - "5 1 8", // p0 + "5 1 8", // p0 "7 0 11")) // p1 tk.MustQuery("show stats_buckets where is_index=1").Check(testkit.Rows( @@ -1204,7 +1204,7 @@ func TestGlobalStatsData2(t *testing.T) { tk.MustQuery("select distinct_count, null_count from mysql.stats_histograms where is_index=1 order by table_id asc").Check( testkit.Rows("12 1", // global, g = p0 + p1 - "5 1", // p0 + "5 1", // p0 "7 0")) // p1 // double + (column + index with 1 column)