fix(storage): check engine closed before collecting index metrics (#16656)

pull/16673/head
Jacob Marble 2020-01-23 15:27:25 -08:00 committed by GitHub
parent 8e9b2a69a7
commit a56e0226e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -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

View File

@ -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
@ -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()
@ -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)
}
@ -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()
}