Fix data race.

pull/9318/head
Ben Johnson 2018-01-15 11:53:49 -07:00
parent d0429dc582
commit e1aff89299
No known key found for this signature in database
GPG Key ID: 81741CD251883081
1 changed files with 5 additions and 1 deletions

View File

@ -1174,7 +1174,11 @@ func (idx *ShardIndex) CreateSeriesListIfNotExists(keys, names [][]byte, tagsSli
// Write entire batch at once if we are well below the max series threshold.
// Otherwise, insert one at a time until we reach an error.
if max := idx.opt.Config.MaxSeriesPerDatabase; max > 0 && len(idx.series)+len(keys) <= max {
idx.mu.RLock()
seriesN := len(idx.series)
idx.mu.RUnlock()
if max := idx.opt.Config.MaxSeriesPerDatabase; max > 0 && seriesN+len(keys) <= max {
if err := idx.Index.CreateSeriesListIfNotExists(idx.id, idx.seriesIDSet, keys, names, tagsSlice, &idx.opt, false); err != nil {
return err
}