Fix race in findGenerations
The file store stats slice is re-used which causes the race below: WARNING: DATA RACE Write at 0x00c42007e140 by goroutine 43: github.com/influxdata/influxdb/tsdb/engine/tsm1.(*FileStore).Stats() /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/file_store.go:511 +0x22e github.com/influxdata/influxdb/tsdb/engine/tsm1.(*DefaultPlanner).findGenerations() /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/compact.go:461 +0x6f github.com/influxdata/influxdb/tsdb/engine/tsm1.(*DefaultPlanner).PlanLevel() Previous read at 0x00c42007e140 by goroutine 40: github.com/influxdata/influxdb/tsdb/engine/tsm1.(*DefaultPlanner).findGenerations() /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/compact.go:463 +0x13d github.com/influxdata/influxdb/tsdb/engine/tsm1.(*DefaultPlanner).PlanOptimize()pull/7533/head
parent
96648d2045
commit
e388912b6c
|
@ -261,7 +261,7 @@ func (f *FileStore) Add(files ...TSMFile) {
|
|||
for _, file := range files {
|
||||
atomic.AddInt64(&f.stats.DiskBytes, int64(file.Size()))
|
||||
}
|
||||
f.lastFileStats = f.lastFileStats[:0] // Will need to be recalculated on next call to Stats.
|
||||
f.lastFileStats = nil
|
||||
f.files = append(f.files, files...)
|
||||
sort.Sort(tsmReaders(f.files))
|
||||
atomic.StoreInt64(&f.stats.FileCount, int64(len(f.files)))
|
||||
|
@ -289,7 +289,7 @@ func (f *FileStore) Remove(paths ...string) {
|
|||
atomic.AddInt64(&f.stats.DiskBytes, -int64(file.Size()))
|
||||
}
|
||||
}
|
||||
f.lastFileStats = f.lastFileStats[:0] // Will need to be recalculated on next call to Stats.
|
||||
f.lastFileStats = nil
|
||||
f.files = active
|
||||
sort.Sort(tsmReaders(f.files))
|
||||
atomic.StoreInt64(&f.stats.FileCount, int64(len(f.files)))
|
||||
|
@ -618,7 +618,7 @@ func (f *FileStore) Replace(oldFiles, newFiles []string) error {
|
|||
// Tell the purger about our in-use files we need to remove
|
||||
f.purger.add(inuse)
|
||||
|
||||
f.lastFileStats = f.lastFileStats[:0] // Will need to be recalculated on next call to Stats.
|
||||
f.lastFileStats = nil
|
||||
f.files = active
|
||||
sort.Sort(tsmReaders(f.files))
|
||||
atomic.StoreInt64(&f.stats.FileCount, int64(len(f.files)))
|
||||
|
|
Loading…
Reference in New Issue