Skip to content
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

WriteApi blocking for up to 30s when InfluxDB is down #623

Open
constantins2001 opened this issue Mar 4, 2024 · 3 comments
Open

WriteApi blocking for up to 30s when InfluxDB is down #623

constantins2001 opened this issue Mar 4, 2024 · 3 comments
Labels
question Further information is requested
Milestone

Comments

@constantins2001
Copy link

constantins2001 commented Mar 4, 2024

Steps to reproduce:

  1. Write data in loop
  2. Take down InfluxDB
  3. Observe large duration of WriteApi#Write

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:

  • Client Version: 3.3.0
  • InfluxDB Version: 2.7.5
  • Platform: Windows
@bednar
Copy link
Contributor

bednar commented Mar 5, 2024

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.

@bednar bednar added the question Further information is requested label Mar 5, 2024
@bednar bednar closed this as not planned Won't fix, can't repro, duplicate, stale Mar 5, 2024
@bednar bednar added this to the 4.15.0 milestone Mar 5, 2024
@constantins2001
Copy link
Author

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

@constantins2001
Copy link
Author

Please reopen

@bednar bednar reopened this Mar 12, 2024
@bednar bednar modified the milestones: 4.15.0, 4.16.0 May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants