diff --git a/tsdb/engine/tsm1/engine.go b/tsdb/engine/tsm1/engine.go index 9d50caa9ab..3b052a3592 100644 --- a/tsdb/engine/tsm1/engine.go +++ b/tsdb/engine/tsm1/engine.go @@ -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)