Skip to content

Commit

Permalink
fix(storage): check engine closed before collecting index metrics (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmarble committed Jan 23, 2020
1 parent 8e9b2a6 commit a56e022
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,9 @@
1. [16504](https://github.com/influxdata/influxdb/pull/16504): Add backup and restore
1. [16522](https://github.com/influxdata/influxdb/pull/16522): Introduce resource logger to tasks, buckets and organizations

### Bug Fixes
1. [16656](https://github.com/influxdata/influxdb/pull/16656): Check engine closed before collecting index metrics

### UI Improvements

1. [16575](https://github.com/influxdata/influxdb/pull/16575): Swap billingURL with checkoutURL
Expand Down
19 changes: 17 additions & 2 deletions storage/engine.go
Expand Up @@ -52,7 +52,7 @@ type Engine struct {
nodeID *int // Not used by default.

mu sync.RWMutex
closing chan struct{} //closing returns the zero value when the engine is shutting down.
closing chan struct{} // closing returns the zero value when the engine is shutting down.
index *tsi1.Index
sfile *tsdb.SeriesFile
engine *tsm1.Engine
Expand Down Expand Up @@ -703,7 +703,7 @@ func (e *Engine) CreateBackup(ctx context.Context) (int, []string, error) {
// FetchBackupFile writes a given backup file to the provided writer.
// After a successful write, the internal copy is removed.
func (e *Engine) FetchBackupFile(ctx context.Context, backupID int, backupFile string, w io.Writer) error {
span, _ := tracing.StartSpanFromContext(ctx)
span, ctx := tracing.StartSpanFromContext(ctx)
defer span.Finish()

e.mu.RLock()
Expand Down Expand Up @@ -762,6 +762,11 @@ func (e *Engine) fetchBackup(ctx context.Context, backupID int, backupFile strin
// InternalBackupPath provides the internal, full path directory name of the backup.
// This should not be exposed via API.
func (e *Engine) InternalBackupPath(backupID int) string {
e.mu.RLock()
defer e.mu.RUnlock()
if e.closing == nil {
return ""
}
return e.engine.FileStore.InternalBackupPath(backupID)
}

Expand Down Expand Up @@ -793,10 +798,20 @@ func (e *Engine) ApplyFnToSeriesIDSet(fn func(*tsdb.SeriesIDSet)) {

// MeasurementCardinalityStats returns cardinality stats for all measurements.
func (e *Engine) MeasurementCardinalityStats() (tsi1.MeasurementCardinalityStats, error) {
e.mu.RLock()
defer e.mu.RUnlock()
if e.closing == nil {
return nil, ErrEngineClosed
}
return e.index.MeasurementCardinalityStats()
}

// MeasurementStats returns the current measurement stats for the engine.
func (e *Engine) MeasurementStats() (tsm1.MeasurementStats, error) {
e.mu.RLock()
defer e.mu.RUnlock()
if e.closing == nil {
return nil, ErrEngineClosed
}
return e.engine.MeasurementStats()
}

0 comments on commit a56e022

Please sign in to comment.