Skip to content

Commit

Permalink
table/tables: fix a DATA RACE in a unit test case (#21733)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored Dec 15, 2020
1 parent f5a3a38 commit 8935ad1
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions table/tables/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,10 @@ func (ts *testSuite) TestConstraintCheckForUniqueIndex(c *C) {
tk2.Exec("insert into ttt(k,c) values(3, 'tidb')")
ch <- 2
}()
// Sleep 100ms for tk2 to execute, if it's not blocked, 2 should have been sent to the channel.
time.Sleep(100 * time.Millisecond)
ch <- 1
tk1.Exec("commit")
var isSession1 string
if 1 == <-ch {
isSession1 = "true"
}
c.Assert(isSession1, Equals, "true")
tk1.MustExec("rollback")
tk2.MustExec("rollback")
// The data in channel is 1 means tk2 is blocked, that's the expected behavior.
c.Assert(<-ch, Equals, 1)
}

0 comments on commit 8935ad1

Please sign in to comment.