Skip to content

[WIP] Setting client side wait_timeout #4901

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

Open
wants to merge 3 commits into
base: v3.0
Choose a base branch
from

Conversation

yashwantsahu20
Copy link
Contributor

Setting client side wait_timeout – current ProxySQL ignores wait_timeout set by the client. If a client specifies a value for wait_timeout , ProxySQL should terminate the client connection (but not the backend connection) when said timeout is reached instead of ProxySQL’s global mysql-wait_timeout . As a further enhancement, the wait timeout specified by the client shouldn’t exceed ProxySQL’s wait_timeout . The implementation also requires adequate TAP test to verify the functionality.

@renecannao
Copy link
Contributor

Brainstorming on implementation details.
Should we perform range validation of wait_timeout specified by the client and return an error if out of range? Or maybe it is easier to silently ignore out of range values? (or maybe write an error in error log without notifying the client).

The previous point is also related to: what happens when we change mysql-wait_timeout at runtime?
Currently, the current mysql-wait_timeout is what is used to determine if the client needs to be disconnected, not the value of mysql-wait_timeout when the client connected. This is used during failover for example, to terminate all clients quickly.
So perhaps we should use the smaller of the two , avoiding out of range validation.

Thoughts?

@yashwantsahu20
Copy link
Contributor Author

yashwantsahu20 commented Apr 2, 2025

Thanks René for very nice suggestions.

Please let me know your thought about this approach.

We can do as following

  1. Let's do a basic range validation as done by MySQL to satisfy third-party tools, tests, etc., and stay aligned with MySQL limits.
    Only minimum and maximum values will be validated. This will return an error to the client.
    Example:
      min - 1
      max - one year

https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_wait_timeout

  1. Add an error message to the error log if the session's wait_timeout value is greater than the global one, but still accept and store the value, as the global timeout may be increased in the future. We need to log a message as client may expect longer session timeout while terminating it.

No need to return an error to the client, since from the client’s perspective, there is no visible failure.

  1. While terminating the connection, we will always pick the smaller of the two values (session wait_timeout and global mysql-wait_timeout).

@renecannao
Copy link
Contributor

SGTM

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.

2 participants