influxdata / influxdata/influxdb
Query last point returns a point with null value
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
Hi, I use a c++ library [last](https://github.com/offa/influxdb-cxx) which use curl to write data to the database.
In my c++ program, I will write 4 measurements and each of them have dozens of pieces points to write per second.
I use udp to send data
```
sensor_->influxdb_ = influxdb::InfluxDBFactory::Get("udp://localhost:8089?db=udp");
```
One of my write point c++ code looks:
```
sensor_->influxdb_->write(influxdb::Point("/controller/data")
.addField("angular", sensor_->angular())
.addField("speed_left_rear", sensor_->speedl()
.addField("speed_right_rear", sensor_->speedr()
.addField("voltage", sensor_->voltage()));
```
It would send a point to measurement "/controller/data". This point has four fields and has no tag.
When I want to query the data in last half second in database, problem occur. I open a terminal and enter
```
influx
use udp
create retention policy "1h" on udp duration 1h replication 1 shard duration 1h default
precision rfc3339
select * form "udp".."/controller/data" where time >= now() - 500ms
```
__Expected behavior:__
I can get last half second's points' with their filed value .
__Actual behavior:__
Sometimes filed vaule in the front columns is null.
For example:

and

As you can see, there are many null value in field angular, left_rear_speed and right_rear_speed.
Left column has a better chance of being null, and the rightmost column of filed key voltage nerver has a null value.
These null value field actually have values, and I can get their value later.
I find that: The filed value in the same row correspond to the same timestamp, but they are not written into database at the same time, some of them may be written in, but others are not. Is that right?
If there is a method to let different field in the same raw to write at the same time, so when I query each field in the same row is not null. I actually want to query the last point in the measurement :`select * from "udp".."/controller/data" order by time desc limit 1`, but it sometimes returns a point with some fields having null value, so I have to query again until there is no null value.
__Environment info:__
I run all these program on a nanopi which is similar to raspberry pi.
* System info: Linux 4.4.179 aarch64
* InfluxDB version: 1.8.7
* Other relevant environment details:
__Config:__
my influx.conf
```
[[udp]]
enabled = true
batch-size = 50
batch-pending = 5
batch-timeout = "1s"
```
Contributor guide
Research direction
Start by reproducing the query against the UDP input configured with batch-size 50, batch-pending 5, and batch-timeout 1s, using the supplied C++ write pattern and InfluxDB 1.8.7 environment. Compare recent SELECT results with later reads to determine whether null fields arise from UDP batching or query behavior. Done means the behavior is explained and either a focused reproduction or a documented correction is provided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100