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

Offset and limit combined with aggregation (group by time) gives incorrect results #6661

Closed
pjmyburg opened this issue May 18, 2016 · 3 comments
Assignees
Milestone

Comments

@pjmyburg
Copy link

Bug report

System info: InfluxDB 0.13.0, Amazon Linux AMI on EC2

Steps to reproduce:

  1. Insert many data points with timestamps over multiple days
  2. Query count of data points and group by time(1d)
  3. Query count of data points and group by time(1d) and offset 1
  4. Query count of data points and group by time(1d) and limit 1

Expected behavior:

  • I expect the first entry in the result of step 3 to match the second entry in the result of step 2.
  • I expect the result of step 4 to match the first entry in the result of step 2.

Actual behavior:

Step 2:

select count(field) from measure where userId = 'abc' and time >= '2016-05-01' group by time(1d)
time count
1462060800000000000 45884
1462147200000000000 83958
1462233600000000000 79540
... ...

Step 3:

select count(field) from measure where userId = 'abc' and time >= '2016-05-01' group by time(1d) offset 1
time count
1462147200000000000 2
1462233600000000000 0
1462320000000000000 0
... ...

Step 4:

select count(field) from measure where userId = 'abc' and time >= '2016-05-01' group by time(1d) limit 1
time count
1462060800000000000 2

As you can see, the timestamps are correctly returned according to the limit and offset, but for some reason the count is also affected.

Additional info:

We just migrated from InfluxDB 0.9.5 to 0.13.0. All steps were followed and the migration was a success. The queries were working on 0.9.5 this morning, but not on 0.13.0. We don't know which version in between resulted in the changed behaviour.
Offset and limit gives the expected behaviour when querying the raw data without aggregation, but gives incorrect results when any aggregation function is applied.

@e-dard e-dard added area/influxql Issues related to InfluxQL query language area/queries and removed area/influxql Issues related to InfluxQL query language labels May 18, 2016
@jsternberg
Copy link
Contributor

I think this is caused by #6391.

@jsternberg jsternberg added this to the 1.0.0 milestone May 18, 2016
jsternberg added a commit that referenced this issue May 18, 2016
The limit optimization was put into the wrong place and caused only part
of the shard to be read when a limit was used. The optimization is
possible, but requires a bit of refactoring to the code here so the call
iterator is created per series before handed to the limit iterator.

Fixes #6661.
jsternberg added a commit that referenced this issue May 19, 2016
The limit optimization was put into the wrong place and caused only part
of the shard to be read when a limit was used. The optimization is
possible, but requires a bit of refactoring to the code here so the call
iterator is created per series before handed to the limit iterator.

Fixes #6661.
@pjmyburg
Copy link
Author

Thanks guys! Any realistic chance of a 0.13.1 with the fix soon or should we roll back to 0.12?

jsternberg added a commit that referenced this issue May 19, 2016
The limit optimization was put into the wrong place and caused only part
of the shard to be read when a limit was used. The optimization is
possible, but requires a bit of refactoring to the code here so the call
iterator is created per series before handed to the limit iterator.

Fixes #6661.
@jsternberg
Copy link
Contributor

I'm going to try and put together the bugfixes that will go into 0.13.1 soon, but if you need this urgently, I personally would downgrade to 0.12 temporarily until we get 0.13.1 out.

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

No branches or pull requests

4 participants