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

Allow turning on TCP keepalive for specific sessions/connections #132

Closed
psarna opened this issue Dec 14, 2020 · 5 comments · Fixed by #395 or #735
Closed

Allow turning on TCP keepalive for specific sessions/connections #132

psarna opened this issue Dec 14, 2020 · 5 comments · Fixed by #395 or #735
Assignees
Milestone

Comments

@psarna
Copy link
Contributor

psarna commented Dec 14, 2020

Context: scylladb/scylladb#7781 (comment)

It can be useful for clients to decide that connections created within a session should/should not be subject to TCP timeouts.

@psarna
Copy link
Contributor Author

psarna commented Dec 14, 2020

Depends on tokio-rs/tokio#3082 - set_keepalive was dropped from Tokio during the 0.2 -> 0.3 transition.

@piodul
Copy link
Collaborator

piodul commented Feb 8, 2022

Leaving a comment with similar insight to the one I left under #394:

We could implement a keepalive now without waiting for tokio to support TCP-level keepalives if we take a similar approach as Java and Python drivers do, namely send a cheap query every keepalive period, e.g. select key from system.local where key = 'local'.

@elbaro
Copy link

elbaro commented Feb 8, 2022

If I want to manually send a cheap query until this is implemented, how can I make sure every connection in the pool is refreshed?

For example, I have 3 nodes, the default connection pool size is 4. If sending every keepalive_period / 12, does the default token-aware round-robin policy will make sure all 12 tcp connections are refreshed?

@psarna
Copy link
Contributor Author

psarna commented Feb 8, 2022

@elbaro it won't be that easy on Scylla, because our driver is also shard-aware, and we try to send data to a specific shard if possible, and also your queries would have to be hand-crafted to hit proper tokens, so that each connection is used eventually (or make a query that's not token-aware, e.g. an unprepared one, but these ones are more expensive). @havaker is working on an internal solution that allows configuring the keepalive period right now, and the solution will make sure that each connection is kept alive if it's configured. Hopefully we'll be able to give you a branch for testing today/tomorrow.

@havaker havaker mentioned this issue Feb 8, 2022
6 tasks
@piodul
Copy link
Collaborator

piodul commented May 10, 2023

I'm reopening this. The #395 implemented CQL-level keepalives which is useful but is not the same as TCP-level keepalives. Some drivers expose both (e.g. cpp driver: https://github.com/scylladb/cpp-driver/blob/eb6b70d138752c5e6a487eeaf69e6baa4d6652a4/include/cassandra.h#L2533-L2536).

According to this comment, it is possible to set TCP keepalives on a tokio socket, although with the help of an external crate.

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