influxdb
influxdb copied to clipboard
Query last point returns a point with null value
Hi, I use a c++ library last 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"
If I modify batch-size to 1 in influxdb.conf
[[udp]]
enabled = true
batch-size = 1
batch-pending = 5
batch-timeout = "1s"
It would adds a lot cpu load, and I can only get point whose time > now -22s
influx
use udp
precision rfc3339
select * from "udp".."/controller/data" where time >= now() - 22s
and it returns the following result:
It still return null value.
So changing the batch-size doesn't work for this problem, and it seems that batch-size only works for one column.
I am also getting null data at the last few (1-2) records. However for my case, its difficult to reproduce the issue consistently.
I also check on stackoverflow and found other with the same issue. https://stackoverflow.com/questions/65620913/why-am-i-receiving-random-null-field-values-on-my-influx-queries
same problem