Open constantins2001 opened 6 months ago
Hello @constantins2001,
Thank you for using our client. I wanted to address your concern about managing data writes to InfluxDB, especially in scenarios where you require immediate feedback for each write operation.
The WriteApi
in our client operates on a background thread, handling data ingestion in batches. This method is designed for efficiency, and it includes a retry mechanism that activates if InfluxDB is temporarily unavailable, according to a predefined configuration. However, this might not always suit use cases where you need to ensure that each write operation has been successfully completed or explicitly handled before proceeding.
For scenarios requiring immediate acknowledgment from InfluxDB for each write, I recommend using the WriteApiAsync
feature of our client. WriteApiAsync
provides an asynchronous, task-based approach to writing data, allowing your application to await responses directly from InfluxDB for every write operation. This method is particularly useful for applications that require strict error handling or confirmation of data ingestion on a per-write basis.
Here's an example to get you started: WriteApiAsyncExample.
This example demonstrates how to use WriteApiAsync to write data and asynchronously wait for a response, providing a clear pattern for implementing similar functionality in your application.
If you have any further questions or require additional assistance, please feel free to reach out.
Best Regards.
Hi @bednar,
I know about the AsyncWriteApi, but it does not suite my use case.
I'm writing many data points (metrics of a running service) to InfluxDB. I don't care if they are received or not. In multiple locations in my codebase (metric collection) I'm calling the write api, expecting it to not delay further execution.
This isn't the case when InfluxDB is down. Specifically, the pipeline sending to InfluxDB isn't accepting new entries while retrying, thus blocking all WriteApi callers for up to retry_window (30s). This is unacceptable for my use case.
As a temporary workaround I'm wrapping the write with Thread.Run, but that's only a temporary solution as it will result (rather sooner than later) in ThreadPool starvation.
Best regards Constantin
Please reopen
Steps to reproduce:
Expected behavior: Even if InfluxDB is down, the Synchronous API doesn't block
Actual behavior: When InfluxDB is down, the Synchronous API block for up to 30s
Specifications: