Not all points being written to InfluxDB using Python

I’m using InfluxDB OSS 2.7 and using the influxdb_client Python library to write data. Right now I am attempting to write a lot of data taken in close intervals to the database, but a lot of the points end up not being written.

import os
from influxdb_client import InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS
from datetime import datetime
import random
import time

DELAY = 0.1

org = "ORG"
client = InfluxDBClient(url="URL", token="TOKEN", org=org)
writeAPI = client.write_api(write_options=SYNCHRONOUS)

points = []

for i in range(21):
    nums = [random.random(),random.random(),random.random()]
    current_time = datetime.now()
    for num, field in zip(nums,["Field1","Field2","Field3"]):
        points.append(Point("MEASUREMENT").tag("DeviceName","DEVICE").field(field,num).time(current_time.astimezone()))
    time.sleep(DELAY)

writeAPI.write("BUCKET",org,points)

The code above simulates my use case, I am collecting data in groups of 3 where each group is very close to one another. When I have a very small delay between groups, not all of the points get written. I am confused about this for two main reasons.

  1. All the points get written when I use a large delay, even though I am writing the entire list at the same time regardless of the delay.
  2. When most of the points don’t get written, there are always one or two groups of 3 that get written. There is never a partial group.

Any ideas for how I can fix this? Is there something I’m missing regarding how InfluxDB handles writes?

Hi,
i was not able to reproduce your problem with your test script even with 0 delay.
I was looking for point erasing by not enough precision on timestamp but it seems to not be the case.
There is no other “natural” explanation for this in my knowledge.

1 Like

Thanks for the reply! I tried to recreate this issue on another computer and unfortunately the issue is still occurring. Since the issue didn’t happen for you, this tells me that I probably setup my local database incorrectly. Are there any settings you know of that could be causing this issue for me?