diff --git a/CHANGELOG.md b/CHANGELOG.md index b81b294e370..1ffda1e8a75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ - [#6427](https://github.com/influxdata/influxdb/pull/6427): Fix setting uint config options via env vars - [#6458](https://github.com/influxdata/influxdb/pull/6458): Make it clear when the CLI version is unknown. - [#3883](https://github.com/influxdata/influxdb/issues/3883): Improve query sanitization to prevent a password leak in the logs. +- [#6462](https://github.com/influxdata/influxdb/pull/6462): Add safer locking to CreateFieldIfNotExists ## v0.12.2 [2016-04-20] diff --git a/tsdb/shard.go b/tsdb/shard.go index 2928448d6f9..00530e4fb8b 100644 --- a/tsdb/shard.go +++ b/tsdb/shard.go @@ -572,6 +572,7 @@ func (m *MeasurementFields) CreateFieldIfNotExists(name string, typ influxql.Dat m.mu.RUnlock() m.mu.Lock() + defer m.mu.Unlock() if f := m.fields[name]; f != nil { return nil } @@ -584,7 +585,6 @@ func (m *MeasurementFields) CreateFieldIfNotExists(name string, typ influxql.Dat } m.fields[name] = f m.Codec = NewFieldCodec(m.fields) - m.mu.Unlock() return nil }