diff --git a/tests/integrations/tso/server_test.go b/tests/integrations/tso/server_test.go index c9c978e7d7f..96fc5d334b0 100644 --- a/tests/integrations/tso/server_test.go +++ b/tests/integrations/tso/server_test.go @@ -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) }