diff --git a/CHANGELOG.md b/CHANGELOG.md index 314c1bfd18..c5ef91b4c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ - [#2300](https://github.com/influxdb/influxdb/pull/2300): Refactor integration tests. Properly close Graphite/OpenTSDB listeners. - [#2338](https://github.com/influxdb/influxdb/pull/2338): Fix panic if tag key isn't double quoted when it should have been - [#2340](https://github.com/influxdb/influxdb/pull/2340): Fix SHOW DIAGNOSTICS panic if any shard was non-local. - +- [#2351](https://github.com/influxdb/influxdb/pull/2351): Fix data race by rlocking shard during diagnostics. ## v0.9.0-rc25 [2015-04-15] diff --git a/server.go b/server.go index b02acd677f..ecf668e282 100644 --- a/server.go +++ b/server.go @@ -3302,7 +3302,7 @@ func (s *Server) DiagnosticsAsRows() []*influxql.Row { for _, n := range sh.DataNodeIDs { nodes = append(nodes, strconv.FormatUint(n, 10)) shardsRow.Values = append(shardsRow.Values, []interface{}{now, strconv.FormatUint(sh.ID, 10), - strings.Join(nodes, ","), strconv.FormatUint(sh.index, 10)}) + strings.Join(nodes, ","), strconv.FormatUint(sh.Index(), 10)}) } // Shard may not be local to this node. if sh.store != nil { diff --git a/shard.go b/shard.go index fd82bd78e7..baff3b1e53 100644 --- a/shard.go +++ b/shard.go @@ -133,6 +133,14 @@ func shardMetaIndex(tx *bolt.Tx) uint64 { return index } +// Index returns the highest Raft index processed by this shard. Shard RLock +// held during execution. +func (s *Shard) Index() uint64 { + s.mu.RLock() + defer s.mu.RUnlock() + return s.index +} + // close shuts down the shard's store. func (s *Shard) close() error { // Wait for goroutines to stop.