diff --git a/server.go b/server.go index 47c5771fb8..49ec02697e 100644 --- a/server.go +++ b/server.go @@ -70,7 +70,7 @@ type Server struct { errors map[uint64]error // message errors meta *metastore // metadata store - metaIndexes map[string]*TagIndex // metadata in-memory index + metaIndexes map[string]*TagIndex // map databases to tag indexes databases map[string]*database // databases by name databasesByShard map[uint64]*database // databases by shard id @@ -942,6 +942,7 @@ func (s *Server) createSeriesIfNotExists(database, name string, tags map[string] s.mu.RLock() idx := s.metaIndexes[database] s.mu.RUnlock() + if _, series := idx.MeasurementAndSeries(name, tags); series != nil { return series.ID, nil } diff --git a/tag_index.go b/tag_index.go index ae0c443c86..4527d47dc3 100644 --- a/tag_index.go +++ b/tag_index.go @@ -11,9 +11,9 @@ import ( // and series within a database. type TagIndex struct { mu sync.RWMutex - measurementIndex map[string]*measurementIndex - seriesToMeasurement map[uint32]*Measurement - series map[uint32]*Series + measurementIndex map[string]*measurementIndex // map measurement name to its tag index + seriesToMeasurement map[uint32]*Measurement // map series id to its measurement + series map[uint32]*Series // map series id to the Series object } func NewTagIndex() *TagIndex {