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

executor: fix the data race on TestDataForTableStatsField and TestPartitionsTable #15260

Merged
merged 14 commits into from
Mar 10, 2020
Prev Previous commit
Next Next commit
add SerialSuites for bug test
  • Loading branch information
reafans committed Mar 10, 2020
commit 5f218129f89c835296e4a867bee165030b32783e
34 changes: 31 additions & 3 deletions executor/infoschema_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package executor_test

import (
"github.com/pingcap/tidb/executor"
"strconv"

. "github.com/pingcap/check"
Expand All @@ -26,12 +27,34 @@ import (
)

var _ = Suite(&testInfoschemaTableSuite{})
var _ = SerialSuites(&testInfoschemaTableSerialSuite{})

type testInfoschemaTableSuite struct {
store kv.Storage
dom *domain.Domain
}

type testInfoschemaTableSerialSuite struct {
store kv.Storage
dom *domain.Domain
}

func (s *testInfoschemaTableSerialSuite) SetUpSuite(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
s.store = store
s.dom = dom
originCfg := config.GetGlobalConfig()
newConf := *originCfg
newConf.OOMAction = config.OOMActionLog
config.StoreGlobalConfig(&newConf)
}

func (s *testInfoschemaTableSerialSuite) TearDownSuite(c *C) {
s.dom.Close()
s.store.Close()
}

func (s *testInfoschemaTableSuite) SetUpSuite(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
Expand Down Expand Up @@ -212,8 +235,11 @@ func (s *testInfoschemaTableSuite) TestUserPrivileges(c *C) {
c.Assert(len(result.Rows()), Greater, 0)
}

func (s *testInfoschemaTableSuite) TestDataForTableStatsField(c *C) {
func (s *testInfoschemaTableSerialSuite) TestDataForTableStatsField(c *C) {
s.dom.SetStatsUpdating(true)
oldExpiryTime := executor.TableStatsCacheExpiry
executor.TableStatsCacheExpiry = 0
defer func() { executor.TableStatsCacheExpiry = oldExpiryTime }()
do := s.dom
h := do.StatsHandle()
h.Clear()
Expand Down Expand Up @@ -258,8 +284,10 @@ func (s *testInfoschemaTableSuite) TestDataForTableStatsField(c *C) {
testkit.Rows("3 18 54 6"))
}

func (s *testInfoschemaTableSuite) TestPartitionsTable(c *C) {
s.dom.SetStatsUpdating(true)
func (s *testInfoschemaTableSerialSuite) TestPartitionsTable(c *C) {
oldExpiryTime := executor.TableStatsCacheExpiry
executor.TableStatsCacheExpiry = 0
defer func() { executor.TableStatsCacheExpiry = oldExpiryTime }()
do := s.dom
h := do.StatsHandle()
h.Clear()
Expand Down