Skip to content

set keep alive probes for mysql connection#122

Merged
kesmit13 merged 3 commits intomainfrom
users/dgala/tcp-keepalive-probes
Apr 13, 2026
Merged

set keep alive probes for mysql connection#122
kesmit13 merged 3 commits intomainfrom
users/dgala/tcp-keepalive-probes

Conversation

@dgalas2
Copy link
Copy Markdown
Contributor

@dgalas2 dgalas2 commented Apr 13, 2026

Summary

Adding socket_options to configure socket connection for mysql client to allow user to configure specific socket options.

Example Use:

import socket
socket_options = {socket.IPPROTO_TCP: {socket.TCP_KEEPIDLE:60, socket.TCP_KEEPINTVL: 30, socket.TCP_KEEPCNT: 5}}
conn = s2.connect(connection_url, results_type="dict",socket_options=socket_options)

@dgalas2 dgalas2 force-pushed the users/dgala/tcp-keepalive-probes branch from d5a50ad to 7e68f36 Compare April 13, 2026 13:48
Copy link
Copy Markdown
Collaborator

@kesmit13 kesmit13 left a comment

Choose a reason for hiding this comment

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

I'm a little concerned about changing a default behavior by this much without a way for the user to change them. These timings are drastically shorter than the defaults. I'm not sure what effect this will have on existing workflows.

@ricardoasmarques
Copy link
Copy Markdown
Contributor

ricardoasmarques commented Apr 13, 2026

I'm a little concerned about changing a default behavior by this much without a way for the user to change them. These timings are drastically shorter than the defaults. I'm not sure what effect this will have on existing workflows.

@kesmit13 Maybe we can make it configurable just like we do for other setting like connect_timeout, max_allowed_packet, etc?

This way user could change it if needed. Would you be ok with that?

@dgalas2
Copy link
Copy Markdown
Contributor Author

dgalas2 commented Apr 13, 2026

I'm a little concerned about changing a default behavior by this much without a way for the user to change them. These timings are drastically shorter than the defaults. I'm not sure what effect this will have on existing workflows.

should we put this behind a parameter, if user sets keep_alive in s2.connect, only then do we set these values. Until we figure out what the underlying problem is we need a way to unblock customers that is simpler than asking them to add code snippets

Comment thread singlestoredb/mysql/connection.py Outdated
Comment thread singlestoredb/mysql/connection.py Outdated
Comment thread singlestoredb/connection.py Outdated
@dgalas2 dgalas2 force-pushed the users/dgala/tcp-keepalive-probes branch from f0fbf9a to e840b88 Compare April 13, 2026 15:22
@dgalas2 dgalas2 force-pushed the users/dgala/tcp-keepalive-probes branch from e840b88 to fe2855f Compare April 13, 2026 15:27
@dgalas2 dgalas2 requested a review from kesmit13 April 13, 2026 15:27
@kesmit13
Copy link
Copy Markdown
Collaborator

This error about dbapi is because the top-level Connection object has a socket_options parameter, so all subclasses must have that specified as well. This would be in http/connection.py:Connection. It doesn't have to do anything with it, but it must be defined.

@dgalas2 dgalas2 force-pushed the users/dgala/tcp-keepalive-probes branch from 52eade7 to a09a161 Compare April 13, 2026 15:54
@dgalas2 dgalas2 requested a review from kesmit13 April 13, 2026 15:55
@dgalas2 dgalas2 force-pushed the users/dgala/tcp-keepalive-probes branch from a09a161 to 210aeca Compare April 13, 2026 16:14
Comment thread singlestoredb/mysql/connection.py Outdated
@dgalas2 dgalas2 force-pushed the users/dgala/tcp-keepalive-probes branch from 210aeca to 785be45 Compare April 13, 2026 17:45
@kesmit13 kesmit13 merged commit 58a1d2e into main Apr 13, 2026
14 checks passed
@kesmit13 kesmit13 deleted the users/dgala/tcp-keepalive-probes branch April 13, 2026 20:31
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.

3 participants