Merge pull request #5514 from influxdata/er-engine-panic

Ensure shards and engine are safely closed
pull/5961/head
Edd Robinson 2016-03-09 18:56:36 +00:00
commit 58c03448aa
3 changed files with 19 additions and 5 deletions

View File

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

View File

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

View File

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