Skip to content

Commit

Permalink
This is an automated cherry-pick of #54137
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
Rustin170506 authored and ti-chi-bot committed Jul 5, 2024
1 parent 4c7f6a1 commit add0835
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/realtikvtest/statisticstest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ go_test(
race = "on",
deps = [
"//pkg/parser/model",
<<<<<<< HEAD
"//pkg/statistics",
=======
"//pkg/statistics/asyncload",
>>>>>>> ba5c6a9bc6a (statistics: add a testcase for issue 54022 (#54137))
"//pkg/testkit",
"//tests/realtikvtest",
"@com_github_stretchr_testify//require",
Expand Down
15 changes: 15 additions & 0 deletions tests/realtikvtest/statisticstest/statistics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import (
"time"

"github.com/pingcap/tidb/pkg/parser/model"
<<<<<<< HEAD
"github.com/pingcap/tidb/pkg/statistics"
=======
"github.com/pingcap/tidb/pkg/statistics/asyncload"
>>>>>>> ba5c6a9bc6a (statistics: add a testcase for issue 54022 (#54137))
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/tests/realtikvtest"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -250,10 +254,13 @@ func TestNoNeedIndexStatsLoading(t *testing.T) {
tk.MustExec("insert into t value(1,1), (2,2);")
h := dom.StatsHandle()
require.NoError(t, h.DumpStatsDeltaToKV(true))
<<<<<<< HEAD
require.Eventually(t, func() bool {
rows := tk.MustQuery("show stats_meta").Rows()
return len(rows) > 0
}, 1*time.Minute, 2*time.Millisecond)
=======
>>>>>>> ba5c6a9bc6a (statistics: add a testcase for issue 54022 (#54137))
require.NoError(t, h.Update(dom.InfoSchema()))
// 4. Try to select some data from this table by ID, it would trigger an async load.
tk.MustExec("set tidb_opt_objective='determinate';")
Expand All @@ -273,15 +280,23 @@ func checkTableIDInItems(t *testing.T, tableID int64) {
done := make(chan bool)

// First, confirm that the table ID is in the items.
<<<<<<< HEAD
items := statistics.HistogramNeededItems.AllItems()
=======
items := asyncload.AsyncLoadHistogramNeededItems.AllItems()
>>>>>>> ba5c6a9bc6a (statistics: add a testcase for issue 54022 (#54137))
for _, item := range items {
if item.TableID == tableID {
// Then, continuously check until it no longer exists or timeout.
go func() {
for {
select {
case <-ticker.C:
<<<<<<< HEAD
items := statistics.HistogramNeededItems.AllItems()
=======
items := asyncload.AsyncLoadHistogramNeededItems.AllItems()
>>>>>>> ba5c6a9bc6a (statistics: add a testcase for issue 54022 (#54137))
found := false
for _, item := range items {
if item.TableID == tableID {
Expand Down

0 comments on commit add0835

Please sign in to comment.