Skip to content

Commit

Permalink
ddl: fix unstable TestMDLStaleRead (#42364)
Browse files Browse the repository at this point in the history
close #42061
  • Loading branch information
tangenta authored Apr 13, 2023
1 parent 8a1e0c4 commit ee9c81e
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions ddl/metadatalocktest/mdl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func TestMDLCacheTable(t *testing.T) {
require.Less(t, ts1, ts2)
}

func TestMDLStealRead(t *testing.T) {
func TestMDLStaleRead(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)
sv := server.CreateMockServer(t, store)

Expand All @@ -621,29 +621,15 @@ func TestMDLStealRead(t *testing.T) {
tk.MustExec("create table t(a int);")
tk.MustExec("insert into t values(1);")

var wg sync.WaitGroup
wg.Add(1)
var ts2 time.Time
var ts1 time.Time

time.Sleep(2 * time.Second)

tk.MustExec("start transaction read only as of timestamp NOW() - INTERVAL 1 SECOND")
tk.MustQuery("select * from t")

go func() {
tkDDL.MustExec("alter table test.t add column b int;")
ts2 = time.Now()
wg.Done()
}()
tkDDL.MustExec("alter table test.t add column b int;")

time.Sleep(2 * time.Second)
ts1 = time.Now()
tk.MustQuery("select * from t").Check(testkit.Rows("1"))
tk.MustExec("commit")

wg.Wait()
require.Greater(t, ts1, ts2)
}

func TestMDLTiDBSnapshot(t *testing.T) {
Expand Down

0 comments on commit ee9c81e

Please sign in to comment.