Fix data not getting reloaded

The optimization to speed up shard loading had the side effect of
skipping adding series to the index that already exist.  The skipping
was in the wrong location and also skipped the shards measurementFields
index which is required in order to query that series in the shard.
pull/6653/head
Jason Wilder 2016-05-18 10:58:23 -06:00
parent c11af949e9
commit d32ad26d27
1 changed files with 8 additions and 6 deletions

View File

@ -379,12 +379,6 @@ func (e *Engine) readFileFromBackup(tr *tar.Reader, shardRelativePath string) er
// database index and measurement fields
func (e *Engine) addToIndexFromKey(shardID uint64, key string, fieldType influxql.DataType, index *tsdb.DatabaseIndex) error {
seriesKey, field := seriesAndFieldFromCompositeKey(key)
// Have we already indexed this series?
ss := index.Series(seriesKey)
if ss != nil {
return nil
}
measurement := tsdb.MeasurementFromSeriesKey(seriesKey)
m := index.CreateMeasurementIndexIfNotExists(measurement)
@ -400,6 +394,14 @@ func (e *Engine) addToIndexFromKey(shardID uint64, key string, fieldType influxq
return err
}
// Have we already indexed this series?
ss := index.Series(seriesKey)
if ss != nil {
// Add this shard to the existing series
ss.AssignShard(shardID)
return nil
}
// ignore error because ParseKey returns "missing fields" and we don't have
// fields (in line protocol format) in the series key
_, tags, _ := models.ParseKey(seriesKey)