Merge pull request #9777 from influxdata/er-index-log
Log information about index version during startuppull/9781/head
commit
ba16268f41
|
@ -369,18 +369,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 {
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/influxdata/influxdb/query"
|
||||
"github.com/influxdata/influxql"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -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++ {
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue