Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statistics: add a testcase for issue 54022 (#54137) #54477

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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