Skip to content

Commit

Permalink
tests: fix Flaky TestMicroserviceTSOServer/TestConcurrentlyReset (#6396)
Browse files Browse the repository at this point in the history
close #6385

Get a copy of now then call base.add, because now is shared by all goroutines and now.add() will add to itself which isn't atomic and multi-goroutine safe.

Signed-off-by: Bin Shi <binshi.bing@gmail.com>
  • Loading branch information
binshi-bing authored Apr 28, 2023
1 parent 400e3bd commit dcfd9ba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/integrations/tso/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ func (suite *tsoServerTestSuite) TestConcurrentlyReset() {
go func() {
defer wg.Done()
for j := 0; j <= 100; j++ {
physical := now.Add(time.Duration(2*j)*time.Minute).UnixNano() / int64(time.Millisecond)
// Get a copy of now then call base.add, because now is shared by all goroutines
// and now.add() will add to itself which isn't atomic and multi-goroutine safe.
base := now
physical := base.Add(time.Duration(2*j)*time.Minute).UnixNano() / int64(time.Millisecond)
ts := uint64(physical << 18)
suite.resetTS(ts, false, false)
}
Expand Down

0 comments on commit dcfd9ba

Please sign in to comment.