Skip to content

Commit

Permalink
Merge pull request #2449 from influxdb/diags_panic
Browse files Browse the repository at this point in the history
Always check if shard is local when accessing its stats
  • Loading branch information
otoolep committed Apr 29, 2015
2 parents 5050162 + 6cbc80f commit cadc4ec
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
4 changes: 2 additions & 2 deletions cmd/influxd/server_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)...)
}

Expand Down Expand Up @@ -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),
Expand Down
4 changes: 3 additions & 1 deletion shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ func (s *Shard) close() error {
if s.store != nil {
_ = s.store.Close()
}
s.stats.Inc("close")
if s.stats != nil {
s.stats.Inc("close")
}
return nil
}

Expand Down

0 comments on commit cadc4ec

Please sign in to comment.