influxdata / influxdata/influxdb

Continuous queries: wrong behavior for first values when using "RESAMPLE EVERY ... FOR"

Open
#14,196 4 comments 2 reactions 0 assignees View on GitHub
1.x
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__Steps to reproduce:__

1. `CREATE DATABASE mydb`

2. Create the continuous query
```
CREATE CONTINUOUS QUERY "cq" ON "mydb"
RESAMPLE EVERY 1m FOR 2m
BEGIN
SELECT last("value") AS "value"
INTO "mydb"."autogen"."mymeasurement"
FROM "mydb"."autogen"."mymeasurment"
GROUP BY time(1m), *
FILL(previous)
END
```

3. **During the same minute:**
```
INSERT mymeasurement,mytag='1' value=1
INSERT mymeasurement,mytag='2' value=2
```

4. `SELECT * from "mydb"."autogen"."mymeasurement"`
```
name: mymeasurement
time mytag value
---- ----- -----
1561461758977401270 '1' 1
1561461759496979918 '2' 2

```

5. Wait a bit (for the continuous query to execute) ... `SELECT * from "mydb"."autogen"."mymeasurement"`
```
name: mymeasurement
time mytag value
---- ----- -----
1561461660000000000 '2' 1
1561461720000000000 '1' 1
1561461720000000000 '2' 2
1561461758977401270 '1' 1
1561461759496979918 '2' 2
```

__Expected behavior:__
```
name: mymeasurement
time mytag value
---- ----- -----
1561461720000000000 '1' 1
1561461720000000000 '2' 2
1561461758977401270 '1' 1
1561461759496979918 '2' 2
```

__Actual behavior:__
```
name: mymeasurement
time mytag value
---- ----- -----
1561461660000000000 '2' 1
1561461720000000000 '1' 1
1561461720000000000 '2' 2
1561461758977401270 '1' 1
1561461759496979918 '2' 2
```

__Environment info:__

* System info: Linux 4.15.0-51-generic x86_64
* InfluxDB version: InfluxDB v1.7.6 (git: 1.7 01c8dd416270f424ab0c40f9291e269ac6921964)
* Other relevant environment details: Using docker **influxdb:1.7.6**

__Config:__
Everything default. As in the public docker image **influxdb:1.7.6** hosted at : https://hub.docker.com/_/influxdb

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the CREATE DATABASE, continuous query, INSERT, and SELECT sequence against InfluxDB 1.7.6 or the referenced Docker image. Compare the first resampled values with the expected output; done means the extra earlier bucket and incorrect first values no longer appear.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go, 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.