offa / influxdb-cxx

InfluxDB C++ client library.
MIT License
117 stars 45 forks source link

Read timeout on InfluxDB-cxx #171

Closed pkoosha closed 9 months ago

pkoosha commented 1 year ago

I have a multi-threaded program that is writing 100k write with 10K batches and at the same time reading values from the same table. I see this error and I have tried a few options however not been successful.

Thread 0: inserting 100000 random rows
Thread 3: inserting 100000 random rows
Thread 1: inserting 100000 random rows
Thread 2: inserting 100000 random rows
Thread 4: inserting 100000 random rows
Thread 5: inserting 100000 random rows
Thread 6: inserting 100000 random rows
Thread 7: inserting 100000 random rows
Exception: influx-cxx [treatCurlResponse]: Timeout was reached
Exception: influx-cxx [treatCurlResponse]: Timeout was reached
Exception: influx-cxx [treatCurlResponse]: Timeout was reached
Exception: influx-cxx [treatCurlResponse]: Timeout was reached
Exception: influx-cxx [treatCurlResponse]: Timeout was reached
Exception: influx-cxx [treatCurlResponse]: Timeout was reached
Exception: influx-cxx [treatCurlResponse]: Timeout was reached
Exception: influx-cxx [treatCurlResponse]: Timeout was reached
terminate called after throwing an instance of 'influxdb::ConnectionError'
  what():  influx-cxx [treatCurlResponse]: Timeout was reached

I tried and increased the write-timeout for coordinator in the influxdb.conf

[coordinator]                                                                                
 The default time a write request will wait until a "timeout" error is returned to the caller.
   write-timeout = "600s"                                                                        
   #max-concurrent-queries = 0                                                               
   #query-timeout** = "0s"       

[http]
#Added these timeouts
read-timeout = "600s"                                                                  
write-timeout = "600s"  

[subscriber]                                                                                                                                                                                                                                                                                                                                                                             
   http-timeout = "1800s"

then I restarted the influxDB. I don't see how to increase the read-timeout and see this is happening. could you please help me on how to increase the timeout from default 10s to something larger? I see that after 10 seconds the timeout is happening.

offa commented 1 year ago

The Http timeout is hardcoded to 10 sec here. For a quick test you can change these two lines.

pkoosha commented 1 year ago

It worked for me. I suggest to add support of changing this. the write and read timeouts vary in the applications.

offa commented 10 months ago

@pkoosha could you have a look at #220? It introduces a new transport configuration which provides support for this option.