Skip to content

Commit

Permalink
Fix race in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Artoul committed Aug 28, 2018
1 parent 9143476 commit 6096598
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/dbnode/storage/series_wired_list_interaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,22 @@ func TestSeriesWiredListConcurrentInteractions(t *testing.T) {
}
}()

start := time.Now().Truncate(blockSize)
var (
start = time.Now().Truncate(blockSize)
startLock = sync.Mutex{}
getAndIncStart = func() time.Time {
startLock.Lock()
t := start
start = start.Add(blockSize)
startLock.Unlock()
return t
}
)

for i := 0; i < 1000; i++ {
wg.Add(1)
go func() {
blTime := start
start = start.Add(blockSize)
blTime := getAndIncStart()
shard.OnRetrieveBlock(id, nil, blTime, ts.Segment{})
wg.Done()
}()
Expand Down

0 comments on commit 6096598

Please sign in to comment.