Fix race on Cache entry

pull/8885/head
Edd Robinson 2017-09-27 17:44:00 +01:00
parent 7fed382dbf
commit d0b81c1e6c
2 changed files with 9 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"sync/atomic"
"time"
"github.com/influxdata/influxdb/influxql"
"github.com/influxdata/influxdb/models"
"github.com/influxdata/influxdb/tsdb"
"github.com/uber-go/zap"
@ -147,6 +148,13 @@ func (e *entry) size() int {
return sz
}
// InfluxQLType returns for the entry the data type of its values.
func (e *entry) InfluxQLType() (influxql.DataType, error) {
e.mu.RLock()
defer e.mu.RUnlock()
return e.values.InfluxQLType()
}
// Statistics gathered by the Cache.
const (
// levels - point in time measures

View File

@ -1331,7 +1331,7 @@ func (e *Engine) onFileStoreReplace(newFiles []TSMFile) {
// load metadata from the Cache
e.Cache.ApplyEntryFn(func(key []byte, entry *entry) error {
fieldType, err := entry.values.InfluxQLType()
fieldType, err := entry.InfluxQLType()
if err != nil {
e.logger.Error(fmt.Sprintf("refresh index (3): %v", err))
return nil