Only access shard stats if shard is local

Fixes issue #2452
pull/2449/head
Philip O'Toole 2015-04-29 08:29:04 -07:00 committed by Philip O'Toole
parent 50501624d5
commit 6cbc80fa50
4 changed files with 11 additions and 4 deletions

View File

@ -4,6 +4,7 @@
### Bugfixes
- [#2446] (https://github.com/influxdb/influxdb/pull/2446): Correctly count number of queries executed. Thanks @neonstalwart
- [#2452](https://github.com/influxdb/influxdb/issues/2452): Fix panic with shard stats on multiple clusters
## v0.9.0-rc28 [04-27-2015]

View File

@ -1449,7 +1449,7 @@ func runTestsData(t *testing.T, testName string, nodes Cluster, database, retent
}
// Ensures that diagnostics can be written to the internal database.
func TestSingleServerDiags(t *testing.T) {
func TestServerDiags(t *testing.T) {
t.Parallel()
testName := "single server integration diagnostics"
if testing.Short() {
@ -1461,7 +1461,7 @@ func TestSingleServerDiags(t *testing.T) {
config := main.NewConfig()
config.Monitoring.Enabled = true
config.Monitoring.WriteInterval = main.Duration(100 * time.Millisecond)
nodes := createCombinedNodeCluster(t, testName, dir, 1, config)
nodes := createCombinedNodeCluster(t, testName, dir, 3, config)
defer nodes.Close()
// Ensure some data shards also exist.

View File

@ -391,6 +391,10 @@ func (s *Server) StartSelfMonitoring(database, retention string, interval time.D
// Shard-level stats.
tags["shardID"] = strconv.FormatUint(s.id, 10)
for _, sh := range s.shards {
if !sh.HasDataNodeID(s.id) {
// No stats for non-local shards.
continue
}
batch = append(batch, pointsFromStats(sh.stats, tags)...)
}
@ -3356,7 +3360,7 @@ func (s *Server) DiagnosticsAsRows() []*influxql.Row {
nodes = append(nodes, strconv.FormatUint(n, 10))
}
var path string
if sh.store != nil {
if sh.HasDataNodeID(s.id) {
path = sh.store.Path()
}
shardsRow.Values = append(shardsRow.Values, []interface{}{now, strconv.FormatUint(sh.ID, 10),

View File

@ -234,7 +234,9 @@ func (s *Shard) close() error {
if s.store != nil {
_ = s.store.Close()
}
if s.stats != nil {
s.stats.Inc("close")
}
return nil
}