influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

Calling top function with too few parameters crashes influxd

Open legendary-jarppi opened this issue 11 years ago • 2 comments

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 derivative(top(value)) FROM eventbus WHERE time > now() - 10h GROUP BY time(10m), endPoint;

results in panic:

    panic: runtime error: invalid memory address or nil pointer dereference 
[signal 0xb code=0x1 addr=0x0 pc=0x72549d]

goroutine 26543 [running]:
github.com/influxdb/influxdb/influxql.MapTop(0x7f71946d7cf0, 0xc820a7e4a0, 0xc82047c060, 0x0, 0x0)
        /tmp/build/src/github.com/influxdb/influxdb/influxql/functions.go:1358 +0x9d
github.com/influxdb/influxdb/influxql.InitializeMapFunc.func1(0x7f71946d7cf0, 0xc820a7e4a0, 0x0, 0x0)
        /tmp/build/src/github.com/influxdb/influxdb/influxql/functions.go:77 +0x40
github.com/influxdb/influxdb/tsdb.(*SelectMapper).nextChunkAgg(0xc8203d2000, 0x0, 0x0, 0x0, 0x0)
        /tmp/build/src/github.com/influxdb/influxdb/tsdb/mapper.go:476 +0xac2
github.com/influxdb/influxdb/tsdb.(*SelectMapper).NextChunk(0xc8203d2000, 0x0, 0x0, 0x0, 0x0)
        /tmp/build/src/github.com/influxdb/influxdb/tsdb/mapper.go:336 +0x2cb
github.com/influxdb/influxdb/tsdb.(*StatefulMapper).NextChunk(0xc820690980, 0xc820045b90, 0x0, 0x0)
        /tmp/build/src/github.com/influxdb/influxdb/tsdb/executor.go:49 +0x4d
github.com/influxdb/influxdb/tsdb.(*SelectExecutor).executeAggregate(0xc82047c4b0, 0xc820a24d20)
        /tmp/build/src/github.com/influxdb/influxdb/tsdb/executor.go:422 +0x785
created by github.com/influxdb/influxdb/tsdb.(*SelectExecutor).Execute
        /tmp/build/src/github.com/influxdb/influxdb/tsdb/executor.go:96 +0xf2

I suppose expected result is that influxdb should respond that top requires to arguments and not running the query at all.

legendary-jarppi avatar Sep 16 '15 12:09 legendary-jarppi

It looks like when top is inside of a call like derivative it didn't get validated properly. Definitely a bug. Thanks for reporting it!

corylanou avatar Sep 16 '15 13:09 corylanou

Verified this still exists in master as of 0.9.5 RC3

corylanou avatar Nov 17 '15 15:11 corylanou