diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb0776b9e..b847fb5fc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -125,8 +125,9 @@ This release also changes how clusters are setup. The config file has changed so - [#5478](https://github.com/influxdata/influxdb/issues/5478): panic: interface conversion: interface is float64, not int64 - [#5475](https://github.com/influxdata/influxdb/issues/5475): Ensure appropriate exit code returned for non-interactive use of CLI. - [#5479](https://github.com/influxdata/influxdb/issues/5479): Bringing up a node as a meta only node causes panic -- [#5504](https://github.com/influxdata/influxdb/issues/5475): create retention policy on unexistant DB crash InfluxDB +- [#5504](https://github.com/influxdata/influxdb/issues/5504): create retention policy on unexistant DB crash InfluxDB - [#5505](https://github.com/influxdata/influxdb/issues/5505): Clear authCache in meta.Client when password changes. +- [#5244](https://github.com/influxdata/influxdb/issues/5244): panic: ensure it's safe to close engine multiple times. ## v0.9.6 [2015-12-09] diff --git a/tsdb/engine/tsm1/engine.go b/tsdb/engine/tsm1/engine.go index e8c7bcb032..4439d1afd4 100644 --- a/tsdb/engine/tsm1/engine.go +++ b/tsdb/engine/tsm1/engine.go @@ -163,8 +163,15 @@ func (e *Engine) Open() error { return nil } -// Close closes the engine. +// Close closes the engine. Subsequent calls to Close are a nop. func (e *Engine) Close() error { + e.mu.RLock() + if e.done == nil { + e.mu.RUnlock() + return nil + } + e.mu.RUnlock() + // Shutdown goroutines and wait. close(e.done) e.wg.Wait() @@ -172,6 +179,7 @@ func (e *Engine) Close() error { // Lock now and close everything else down. e.mu.Lock() defer e.mu.Unlock() + e.done = nil // Ensures that the channel will not be closed again. if err := e.FileStore.Close(); err != nil { return err diff --git a/tsdb/shard.go b/tsdb/shard.go index e5662ff00b..10029ebcc3 100644 --- a/tsdb/shard.go +++ b/tsdb/shard.go @@ -160,10 +160,15 @@ func (s *Shard) Close() error { } func (s *Shard) close() error { - if s.engine != nil { - return s.engine.Close() + if s.engine == nil { + return nil } - return nil + + err := s.engine.Close() + if err == nil { + s.engine = nil + } + return err } // DiskSize returns the size on disk of this shard