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

Implement client-side timeouts #304

Closed
psarna opened this issue Sep 29, 2021 · 4 comments · Fixed by #522
Closed

Implement client-side timeouts #304

psarna opened this issue Sep 29, 2021 · 4 comments · Fixed by #522
Assignees

Comments

@psarna
Copy link
Contributor

psarna commented Sep 29, 2021

In certain cases (e.g. when a node dies) it's important to be able to set a client-side timeout which gives up on a request after specified time - and optionally retries on another connection. While at it, it's very important to remember that stream_ids must not be reused right after client-side timeout occurs - otherwise, future requests might receive responses directed to some other request that timed out.

@piodul
Copy link
Collaborator

piodul commented Sep 29, 2021

It is possible to cancel requests right now, without the driver's explicit support for timeouts. You can just stop waiting for the future returned by e.g. session.execute() - this should work:

tokio::time::timeout(Duration::from_secs(10), session.execute(statement));

In the meantime, the stream ID won't be removed until the response arrive from the node.

@kbr-
Copy link

kbr- commented Sep 29, 2021

In the meantime, the stream ID won't be removed until the response arrive from the node.

Which it never may e.g. due to shedding, so we can leak stream IDs and channels (they will keep using memory until the connection is closed).

@piodul
Copy link
Collaborator

piodul commented Sep 29, 2021

In the meantime, the stream ID won't be removed until the response arrive from the node.

Which it never may e.g. due to shedding, so we can leak stream IDs and channels (they will keep using memory until the connection is closed).

Yes. It would be nice to fix this along with the following issue: #305 - we could remove the oneshot channel from the handler map when the corresponding future is removed. The stream ID would still be kept allocated in the stream ID bitmap until the response arrives, or until the connection is closed if the request was shed.

@psarna psarna self-assigned this Nov 3, 2021
@psarna psarna assigned havaker and unassigned psarna Nov 19, 2021
@psarna psarna assigned wprzytula and unassigned havaker Aug 12, 2022
@psarna
Copy link
Contributor Author

psarna commented Aug 12, 2022

@wprzytula let's consider the following granularity:

  1. session-wise request_timeout parameter
  2. prepared-statement-wise timeout parameter, which takes precedence over the per-session one, but if it's not present, then the default one from the session is used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants