Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.9.3] First or last value of GROUP BY time(x) is often null #3926

Closed
zimbatm opened this issue Sep 1, 2015 · 4 comments · Fixed by #4038
Closed

[0.9.3] First or last value of GROUP BY time(x) is often null #3926

zimbatm opened this issue Sep 1, 2015 · 4 comments · Fixed by #4038
Assignees
Milestone

Comments

@zimbatm
Copy link

zimbatm commented Sep 1, 2015

For some reason the GROUP BY time(x) queries always return the first value as null. (even if data is available at that time). It also does the same for larger interval.

# Setup
curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"
curl -G http://localhost:8086/query --data-urlencode "q=CREATE RETENTION POLICY myrp ON mydb DURATION 365d REPLICATION 1 DEFAULT"

# Write lots of data
curl -X POST "http://localhost:8086/write?db=mydb" --data-binary "cpu,region=useast,host=server_1,service=redis value=61"

# The query
curl -G http://localhost:8086/query --data-urlencode "db=mydb" --data-urlencode "q=SELECT MEAN(value) FROM cpu WHERE time > now() - 5s GROUP BY time(5s)"

Example response:

{"results":[{"series":[{"name":"cpu","columns":["time","mean"],"values":[["2015-09-01T14:05:10Z",null],["2015-09-01T14:05:15Z",61]]}]}]}
@beckettsean
Copy link
Contributor

There's definitely something amiss with the first bucket in the returns, but not always:

> select count(value) from cpu_idle where time > now() - 60s group by time(10s)
name: cpu_idle
--------------
time            count
2015-09-01T20:01:40Z    9
2015-09-01T20:01:50Z    9
2015-09-01T20:02:00Z    18
2015-09-01T20:02:10Z    9
2015-09-01T20:02:20Z    18
2015-09-01T20:02:30Z    9
2015-09-01T20:02:40Z    9

Notice the value of 9 for '2015-09-01T20:01:40Z'.

Query again a few seconds later. Everything else is the same but the "1:40" bucket is null.

> select count(value) from cpu_idle where time > now() - 60s group by time(10s)
name: cpu_idle
--------------
time            count
2015-09-01T20:01:40Z    
2015-09-01T20:01:50Z    9
2015-09-01T20:02:00Z    18
2015-09-01T20:02:10Z    9
2015-09-01T20:02:20Z    18
2015-09-01T20:02:30Z    9
2015-09-01T20:02:40Z    9

Query again a few seconds later, and now the "1:50" bucket is first and is null, instead of 18.

> select count(value) from cpu_idle where time > now() - 60s group by time(10s)
name: cpu_idle
--------------
time            count
2015-09-01T20:01:50Z    
2015-09-01T20:02:00Z    18
2015-09-01T20:02:10Z    9
2015-09-01T20:02:20Z    18
2015-09-01T20:02:30Z    9
2015-09-01T20:02:40Z    18
2015-09-01T20:02:50Z    

@beckettsean
Copy link
Contributor

It actually can affect the first and/or last bucket:

> select count(value) from cpu_idle where time > now() - 60s group by time(10s)
name: cpu_idle
--------------
time            count
2015-09-01T20:05:10Z    9
2015-09-01T20:05:20Z    9
2015-09-01T20:05:30Z    18
2015-09-01T20:05:40Z    9
2015-09-01T20:05:50Z    18
2015-09-01T20:06:00Z    9
2015-09-01T20:06:10Z    9

> select count(value) from cpu_idle where time > now() - 60s group by time(10s)
name: cpu_idle
--------------
time            count
2015-09-01T20:05:20Z    9
2015-09-01T20:05:30Z    18
2015-09-01T20:05:40Z    9
2015-09-01T20:05:50Z    18
2015-09-01T20:06:00Z    9
2015-09-01T20:06:10Z    18
2015-09-01T20:06:20Z    

> select count(value) from cpu_idle where time > now() - 60s group by time(10s)
name: cpu_idle
--------------
time            count
2015-09-01T20:05:20Z    
2015-09-01T20:05:30Z    18
2015-09-01T20:05:40Z    9
2015-09-01T20:05:50Z    18
2015-09-01T20:06:00Z    9
2015-09-01T20:06:10Z    18
2015-09-01T20:06:20Z    9

@beckettsean beckettsean added this to the 0.9.4 milestone Sep 1, 2015
@beckettsean beckettsean changed the title [0.9.3] First value of GROUP BY time(5s) always null [0.9.3] First or last value of GROUP BY time(x) is often null Sep 1, 2015
@beckettsean
Copy link
Contributor

This doesn't seem to happen for queries with explicit lower and upper time bounds.

@zimbatm
Copy link
Author

zimbatm commented Sep 2, 2015

I can confirm I also saw the null timestamp in the front but I wasn't sure if maybe the data hadn't synched between the various nodes yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants