Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log information about index version during startup #9777

Merged
merged 2 commits into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tsdb/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,21 @@ func (s *Shard) close() error {
return err
}

// IndexType returns the index version being used for this shard.
//
// IndexType returns the empty string if it is called before the shard is opened,
// since it is only that point that the underlying index type is known.
func (s *Shard) IndexType() string {
s.mu.RLock()
defer s.mu.RUnlock()
if err := s.ready(); err != nil {
if s._engine == nil || s.index == nil { // Shard not open yet.
return ""
}

return s.index.Type()
}

// ready determines if the Shard is ready for queries or writes.
// It returns nil if ready, otherwise ErrShardClosed or ErrShardDiabled
// It returns nil if ready, otherwise ErrShardClosed or ErrShardDisabled
func (s *Shard) ready() error {
var err error
if s._engine == nil {
Expand Down
23 changes: 22 additions & 1 deletion tsdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/influxdata/influxdb/query"
"github.com/influxdata/influxql"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

var (
Expand Down Expand Up @@ -322,12 +323,16 @@ func (s *Store) loadShards() error {
}

resC <- &res{s: shard}
log.Info("Opened shard", zap.String("path", path), zap.Duration("duration", time.Since(start)))
log.Info("Opened shard", zap.String("index_version", shard.IndexType()), zap.String("path", path), zap.Duration("duration", time.Since(start)))
}(db.Name(), rp.Name(), sh.Name())
}
}
}

// indexVersions tracks counts of the number of different types of index
// being used within each database.
indexVersions := make(map[string]map[string]int)

// Gather results of opening shards concurrently, keeping track of how
// many databases we are managing.
for i := 0; i < n; i++ {
Expand All @@ -337,9 +342,25 @@ func (s *Store) loadShards() error {
}
s.shards[res.s.id] = res.s
s.databases[res.s.database] = struct{}{}

if _, ok := indexVersions[res.s.database]; !ok {
indexVersions[res.s.database] = make(map[string]int, 2)
}
indexVersions[res.s.database][res.s.IndexType()]++
}
close(resC)

// Check if any databases are running multiple index types.
for db, idxVersions := range indexVersions {
if len(idxVersions) > 1 {
var fields []zapcore.Field
for idx, cnt := range idxVersions {
fields = append(fields, zap.Int(fmt.Sprintf("%s_count", idx), cnt))
}
s.Logger.Warn("Mixed shard index types", append(fields, logger.Database(db))...)
}
}

// Enable all shards
for _, sh := range s.shards {
sh.SetEnabled(true)
Expand Down