Skip to content

Conversation

@NguyenHoangSon96
Copy link
Contributor

@NguyenHoangSon96 NguyenHoangSon96 commented Sep 19, 2025

Closes #

Proposed Changes

  • Query and write timeout will not be passed directly to the transport. It will be passed to the query or write functions.
  • Users can pass a timeout directly to the query and write APIs now, and they will have the highest priority.

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • Tests pass
  • Commit messages are conventional
  • Sign CLA (if not already signed)

@NguyenHoangSon96 NguyenHoangSon96 added this to the 1.5.0 milestone Sep 19, 2025
@NguyenHoangSon96 NguyenHoangSon96 self-assigned this Sep 19, 2025
Copy link
Contributor

@karel-rehor karel-rehor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good for passing timeout arguments to underlying APIs. Maybe I've missed something, but I don't see client properties like writeTimeout and queryTimeout

To synchronize changes with other libraries, in addition to sending a timeout value as a function argument, we also need to set a default writeTimeout and queryTimeout value when instantiating the client or its configuration. This especially needs to be used on the query side (https://grpc.io/docs/guides/deadlines/#deadlines-on-the-client and https://grpc.io/blog/deadlines/).

Having a client property that gets reused with every call will be much more convenient for users, than having to set the timeout with every call.

Copy link
Contributor

@vlastahajek vlastahajek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why flood the write and query API with the timeout parameter?
Is it really necessary to change the timeout for each call?

queryTimeout is already part of the options and is used correctly.
We could add just writeTimeout to properly differentiate values.

@NguyenHoangSon96
Copy link
Contributor Author

Why flood the write and query API with the timeout parameter? Is it really necessary to change the timeout for each call?

queryTimeout is already part of the options and is used correctly. We could add just writeTimeout to properly differentiate values.

  • The queryTimeout and writeTimeout were "flushed" for each call because maybe there are some cases where users want to override the timeout for only a specific query; It also makes the APIs consistent with other libraries. Now users can set a one-time timeout.

@vlastahajek
Copy link
Contributor

The queryTimeout and writeTimeout were "flushed" for each call because maybe there are some cases where users want to override the timeout for only a specific query;

Maybe? We should be pretty sure about use-cases before changing API.

It also makes the APIs consistent with other libraries. Now users can set a one-time timeout.

What other libraries have the timeout parameter in the insert and query-like functions? I've checked Mongo and Postgresql and haven't found that.
Of course, there are already WriteOptions and QueryOptions parts for write and query functions.
If needed, the timeout parameter should be part of those, instead of adding a new parameter.

@NguyenHoangSon96
Copy link
Contributor Author

NguyenHoangSon96 commented Oct 1, 2025

The queryTimeout and writeTimeout were "flushed" for each call because maybe there are some cases where users want to override the timeout for only a specific query;

Maybe? We should be pretty sure about use-cases before changing API.

It also makes the APIs consistent with other libraries. Now users can set a one-time timeout.

What other libraries have the timeout parameter in the insert and query-like functions? I've checked Mongo and Postgresql and haven't found that. Of course, there are already WriteOptions and QueryOptions parts for write and query functions. If needed, the timeout parameter should be part of those, instead of adding a new parameter.

I'm not talking about other libraries like Mongo or Posgrest, but our client libs like influxdb3-java, influxdb3-python, influxdb3-go,....

@vlastahajek
Copy link
Contributor

Neither of the other InfuxDB 3 client libraries has a timeout as a parameter of the write or query function.

@NguyenHoangSon96
Copy link
Contributor Author

Neither of the other InfuxDB 3 client libraries has a timeout as a parameter of the write or query function.

Hi @vlastahajek
Ok, so there are some misunderstandings between me and Karel regarding how we should pass the timeout to functions.
I have changed the code to use QueryOptions and WriteOptions.
Please check again.

@karel-rehor
Copy link
Contributor

karel-rehor commented Oct 6, 2025

@NguyenHoangSon96, @vlastahajek
The main point that arose from working on the Tarana EAR was that on the query side the gRPC error DeadlineExceeded should be triggered and captured, when the user defines a timeout directly or as a gRPC deadline option. So timeout should be an optional argument in a method call or an optional parameter in the configuration. Additionally the GRPC developers recommend setting deadlines (i.e. timeouts):

By default, gRPC does not set a deadline which means it is possible for a client to end up waiting for a response effectively forever. To avoid this you should always explicitly set a realistic deadline in your clients.

When working on the python client I added timeout as a handled known kwarg on query methods. The argument _request_timeout was already being used for write methods. I considered it a potentially useful feature to be able to override the timeout set in the client configuration with an optional argument in the call method. Note that in other clients, like the Java client, the deadline can be set as part of the gRPC options call argument. But this is a bit hidden for some users.

Copy link
Contributor

@karel-rehor karel-rehor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some problems with some of the deprecated fields. queryTimeout is already an important value passed to the GrpcTransport, and likely should not be removed. It is also self descriptive. The option timeout can also simply be made more specific by creating a writeTimeout field which fulfills the same function.

...writeOptions?.headers,
},
gzipThreshold: writeOptionsOrDefault.gzipThreshold,
timeout: writeOptions?.timeout ?? this._options.timeout,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
timeout: writeOptions?.timeout ?? this._options.timeout,
timeout: writeOptions?.timeout ?? this._options.writeTimeout,

I don't see the new writeTimeout option anywhere used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already set in file InfluxDBClient line 133.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line you mentioned in the InfluxDBClient doesn't use writeTimeout.

In fact, the line 145 here should be only:

timeout: writeOptions?.timeout

because sendOptions are optional.

Copy link
Contributor Author

@NguyenHoangSon96 NguyenHoangSon96 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, line 133 in the file "InfluxDBClient" already sets the timeout inside the options object
timeout: this._options.writeOptions?.timeout ?? this._options.timeout,

, so in the file "WriteApiImpl", line 145, I just need to check between timeout in the options object with the timeout passed directly to the doWrite function through the writeOptions object.
timeout: writeOptions?.timeout ?? this._options.timeout,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained here

Comment on lines 129 to 134
this._transport = impl.writeTransport(this._options)
this._writeApi = new WriteApiImpl({
transport: this._transport,
...this._options,
timeout: this._options.writeOptions?.timeout ?? this._options.timeout,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this._transport = impl.writeTransport(this._options)
this._writeApi = new WriteApiImpl({
transport: this._transport,
...this._options,
timeout: this._options.writeOptions?.timeout ?? this._options.timeout,
})
this._transport = impl.writeTransport({
...this._options,
writeTimeout: this._options.writeOptions?.timeout ?? this._options.writeTimeout
})
this._writeApi = new WriteApiImpl({
transport: this._transport,
...this._options,
})

passing an explicit timeout doesn't have an effect, because transport is pre-created and passed. Still, you used the deprecated timeout instead of writeTimeout

...headers,
...sendOptions.headers,
},
timeout: sendOptions.timeout ?? this._defaultOptions.timeout,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
timeout: sendOptions.timeout ?? this._defaultOptions.timeout,
timeout: sendOptions.timeout ?? this._defaultOptions.writeTimeout,

Utilize writeTimeout passed via WriteApi from InfluxDBClient

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just thought that NodeHttpTransport should stay away from our "write" logic timeout, so it should only care about the 'timeout" but shouldn't care if it is "writeTimeout" or whatever "....Timeout".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And in the file "InfluxDBClient" line 133, when initializing the NodeHttpTransport, I set the "timeout"
timeout: this._options.writeOptions?.timeout ?? this._options.timeout,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just thought that NodeHttpTransport should stay away from our "write" logic timeout, so it should only care about the timeout but shouldn't care if it is "writeTimeout" or whatever "....Timeout".

NodeHttpTransport has ConnectionOptions as a constructor parameter, so it cannot ignore the deprecation of the timeout option and add a new writeTimeout option.

And in the file "InfluxDBClient" line 133, when initializing the NodeHttpTransport, I set the "timeout": this._options.writeOptions?.timeout ?? this._options.timeout,`

The timeout option is deprecated. We should not use our own deprecated parts, but use the new ones.

...writeOptions?.headers,
},
gzipThreshold: writeOptionsOrDefault.gzipThreshold,
timeout: writeOptions?.timeout ?? this._options.timeout,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line you mentioned in the InfluxDBClient doesn't use writeTimeout.

In fact, the line 145 here should be only:

timeout: writeOptions?.timeout

because sendOptions are optional.

@vlastahajek
Copy link
Contributor

Also, current tests don't validate correct timeout propagation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants