influxdb
influxdb copied to clipboard
Invalid query crashes influxd
version: 0.9.4.1 rpm: https://s3.amazonaws.com/influxdb/influxdb_0.9.4.1_amd64.deb system: amazon linux 3.14.35-28.38.amzn1.x86_64
Running query:
select host, sum(value)/10 from time_series group by time(10s), host
crashes influxd:
panic: runtime error: index out of range
goroutine 1017 [running]:
github.com/influxdb/influxdb/influxql.newEchoProcessor.func1(0xc82062de00, 0x2, 0x3, 0xc82062de30, 0x3)
/Users/jari.sukanen/code/golang/src/github.com/influxdb/influxdb/influxql/result.go:151 +0x42
github.com/influxdb/influxdb/influxql.newBinaryExprEvaluator.func4(0xc82062de00, 0x2, 0x3, 0x0, 0x0)
/Users/jari.sukanen/code/golang/src/github.com/influxdb/influxdb/influxql/result.go:199 +0x6c
github.com/influxdb/influxdb/tsdb.processForMath(0xc82019a5d0, 0x2, 0x2, 0xc8201ebea0, 0x1, 0x1, 0x0, 0x0, 0x0)
/Users/jari.sukanen/code/golang/src/github.com/influxdb/influxdb/tsdb/executor.go:989 +0x44c
github.com/influxdb/influxdb/tsdb.(*SelectExecutor).executeAggregate(0xc82062ce70, 0xc820160360)
/Users/jari.sukanen/code/golang/src/github.com/influxdb/influxdb/tsdb/executor.go:534 +0x1944
created by github.com/influxdb/influxdb/tsdb.(*SelectExecutor).Execute
/Users/jari.sukanen/code/golang/src/github.com/influxdb/influxdb/tsdb/executor.go:96 +0xf2
This can be easily reproduced by adding following query to cmd/influxd/run/server_test.go TestServer_Query_Tags function:
&Query{
name: "group by tag with aggregate function",
command: `SELECT host, sum(value)/10 FROM db0.rp0.cpu GROUP by host`,
exp: fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","tags":{"host":"server01"},"columns":["time","value"],"values":[["%s",100]]},{"name":"cpu","tags":{"host":"server02"},"columns":["time","value"],"values":[["%s",50]]}]}]}`, now.Format(time.RFC3339Nano), now.Add(1).Format(time.RFC3339Nano)),
},
this should give an error about mixing aggregate and non-aggregate values in the SELECT clause. Not sure why it's not.
This is parser bug. I've attempted to fix it in https://github.com/influxdb/influxdb/pull/4342 however the fix feels a bit hacky and I am not 100% sure it is correct. Please review and comment.