influxdata / influxdata/influxdb

Doesn't show all datapoints on group by

Open
#16,046 3 comments 0 reactions 0 assignees View on GitHub
1.x need more info
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__Steps to reproduce:__
`SELECT "srssi" FROM "2" WHERE time >= now() - 30m` returns all datapoints which I want, but when I use this query `SELECT mean("srssi") FROM "2" WHERE time >= now() - 30m GROUP BY time(1s) fill(none)` some of the latest datapoints are missing.

```
> SELECT "srssi" FROM "2" WHERE time >= now() - 30m
name: 2
time srssi
---- -----
2019-11-26T14:39:01Z 10
2019-11-26T14:39:06Z 10
2019-11-26T14:43:28.293Z 10
2019-11-26T14:43:33.248Z 10
2019-11-26T14:47:38.821Z 10
2019-11-26T14:47:43.82Z 10
2019-11-26T14:51:50.462Z 10
2019-11-26T14:51:55.609Z 10
2019-11-26T15:00:00Z 10
2019-11-26T15:04:00Z 10
2019-11-26T15:08:00Z 10
2019-11-26T15:12:00Z 10
2019-11-26T15:17:00Z 10
> SELECT mean("srssi") FROM "2" WHERE time >= now() - 30m GROUP BY time(1s) fill(none)
name: 2
time mean
---- ----
2019-11-26T14:39:01Z 10
2019-11-26T14:39:06Z 10
2019-11-26T14:43:28Z 10
2019-11-26T14:43:33Z 10
2019-11-26T14:47:38Z 10
2019-11-26T14:47:43Z 10
2019-11-26T14:51:50Z 10
2019-11-26T14:51:55Z 10
2019-11-26T15:00:00Z 10
2019-11-26T15:04:00Z 10
```

__Expected behavior:__
Get all datapoints of the last 30 mins.

__Actual behavior:__
When I query the datapoints with `SELECT mean("srssi") FROM "2" WHERE time >= now() - 30m GROUP BY time(1s) fill(none)` some of the latest datapoints are missing.

__Environment info:__
* System info: Linux 5.0.0-32-generic x86_64
* InfluxDB version: InfluxDB v1.7.7
Influx is running inside a docker container. Image: influxdb:1.7.7

__Additional info:__
This worked fine when Influx was adding the timestamp. Now I am adding my own timestamp (in this format `2019-11-26T15:56:16.742572248Z`). I tried addjusting the time_precision first to seconds than to minutes but this doesnt solve the problem. It also looks like that the time is stored in the same format as the generated one from influx.
I use the python influxdb lib for adding datapoints.

Contributor guide

Open the contributing guide

Research direction

Reproduce the two queries against InfluxDB v1.7.7 using explicit nanosecond timestamps in the Docker setup, then compare the raw results with the time(1s) GROUP BY results. Trace the query engine's time bucketing and timestamp-precision handling, and add a regression test that preserves all datapoints in the final bucket.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.