Add safer unlock to CreateFieldIfNotExists

A deadlock can occur if the field was created while we were waiting for the lock.
pull/6462/head
Tait Clarridge 2016-04-25 10:45:14 -04:00
parent 40e234539b
commit df0e16a92f
2 changed files with 2 additions and 1 deletions

View File

@ -43,6 +43,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.1 [2016-04-08]

View File

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