-
Notifications
You must be signed in to change notification settings - Fork 185
Occasionally losing data points along with error message: "The batch item wasn't processed successfully because: (400) {"code":"invalid","message":"writing requires points"}" #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A little more investigation seems to point to the error being associated with the flush_interval. |
@joeyhagedorn thanks! we will take a look. |
Thanks! I suspect the root cause is related to the very low flush_interval—I misunderstood this earlier as number of points, not milliseconds—however I'd still not expect it to drop points, even if it were specified with a low value. |
Yeah, it should write everything into database. Thanks for precise description of bug |
Hi @joeyhagedorn, I tried to simulate it but everything works fine for me. Could you try it again? I prepared a following "test-case": One small glitch to your code, at the end you should call: Regards |
Hrm… testing again today seems to have 100% resolved this original problem I had been encountering. It reproduced 100% before with the sample code I supplied at the time, and doesn't reproduce at all anymore. I changed the "delay" to 0.1 seconds so I could try many more iterations and after a while, found that one data point was dropped. I did once encounter this error:
and subsequently found that the point being uploaded was indeed dropped and not retried:
Perhaps the original In an effort to exacerbate the problem, i changed the flush_interval to "1", and ran your example repeatedly:
|
Hi @joeyhagedorn, The I was able to simulate and fix issue about empty request:
see - #85 I will continue to investigate why are points dropped when is flush_interval set to '1'. FYI: library try to retry if a reason is Regards |
Awesome, thanks for the thorough investigation. |
I am facing the same / very similar issue. I am using the following parameters:
Tried with flush interval of 1, 5, 10, 20, 25 ... . I didn't find the exact level where I lose data. I don't need to flush my data this fast, but as @joeyhagedorn said: this shouldn't occur. Even though not all data is saved to InfluxDB, I don't get any errors (debug mode is enabled). It might be a memory leak. I don't see much load on my InfluxDB server. On my "client" server I see that one core is used for about 80% (I should look if I could parallelize the workload). FYI, server specs (InfluxDB):
Client is running on another VM, same server, 32GB RAM. Using 1.8.0.dev0 client version, Influx version is InfluxDB 2.0.0-beta.10 (will check if beta 12 solves the issue). |
Tested with stable release (1.8.0) and InfluxDB 2.0.0-beta.12 as well. Like expected, the issue still exists. |
@Eslih thanks for detail info |
Hi there, I encounter this problem too: |
Hi @Neocryan, Could you share a little bit more about how you use a client? Code snippet will be helpful. Could you also enable client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org", debug=True) and check that the response from InfluxDB is correct? For your purpose (500 points daily) is ideal to use a default synchronous write: from influxdb_client import InfluxDBClient, Point
from influxdb_client .client.write_api import SYNCHRONOUS
client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org")
write_api = client.write_api(write_options=SYNCHRONOUS)
write_api.write(bucket="my-bucket", record=data)
client.__del__() Regards |
Hi @bednar, SYNCHRONOUS works, thanks! |
(I think) this can be closed now. "Writing requires points" was a server-side error from InfluxDB Cloud, and it was recently removed. Empty request bodies will now return |
The issue seems to be fixed. Please use The following script was used for testing: import time
from datetime import datetime
from influxdb_client import InfluxDBClient, WriteOptions, Point
url = "https://us-west-2-1.aws.cloud2.influxdata.com"
token = "..."
org = "..."
bucket = "..."
measurement = "python-loosing-data_" + str(datetime.now())
with InfluxDBClient(url=url, token=token, debug=False) as client:
options = WriteOptions(batch_size=8, flush_interval=8, jitter_interval=0, retry_interval=1000)
with client.write_api(write_options=options) as write_api:
for i in range(50):
valOne = float(i)
valTwo = float(i) + 0.5
pointOne = Point(measurement).tag("sensor", "sensor1").field("PSI", valOne).time(time=datetime.utcnow())
pointTwo = Point(measurement).tag("sensor", "sensor2").field("PSI", valTwo).time(time=datetime.utcnow())
write_api.write(bucket, org, [pointOne, pointTwo])
print("PSI Readings: (%f, %f)" % (valOne, valTwo))
time.sleep(0.5)
query = f'from(bucket: "{bucket}") |> range(start: 0) |> filter(fn: (r) => r["_measurement"] == "{measurement}") |> count()'
tables = client.query_api().query(query, org)
for table in tables:
for record in table.records:
print(f'{record.get_measurement()}: {record.get_field()} count: {record.get_value()}')
print("end") |
I've been encountering occasional errors with a really simple python program to write batches of points. I thought my usage was more-or-less very basic, so I'm not clear why this is happening. Perhaps the batching machinery is improperly creating empty batches and dropping points?
I get many log messages like the following:
Observe how the chronograf.csv data is missing some values like (0, 9, 27, 30, 36, etc).
I've attached some sample code, sample local output, and a sample CSV exported from InfluxDB explorer UI.
Also attached in this Gist for nice formatting.
SampleCode.py.txt
LocalOutput.txt
2020-04-11-16-47_chronograf_data.csv.txt
Configuration Info:
InfluxDB version: InfluxDB Cloud 2.0
influxdb_client python module version: 1.5.0
Python version: 3.7.3
OS: Raspbian Linux (Buster)
The text was updated successfully, but these errors were encountered: