sysown / proxysql

High-performance MySQL proxy with a GPL license.
http://www.proxysql.com
GNU General Public License v3.0
6.05k stars 983 forks source link

Fix busy-wait on client SSL connection #4588

Closed JavierJF closed 3 months ago

JavierJF commented 4 months ago

Main Fix

This PR fixes the following busy-loop scenario when handling SSL client connections, the description is in terms of reads handling within MySQL_Data_Stream::read_from_net function:

  1. A client connection was closed, leading to a return of 0 by 'recv', and 'errno' to be set with 'EAGAIN'.
  2. Error handling is performed taking into account a never performed call to 'SSL_read' (as if this '0' was a result for this call).
  3. The call to 'SSL_get_error' returns with 'SSL_ERROR_SYSCALL', as a result of using this invalid param of '0' (which for 'SSL_read' would mean non-retryable error), and the non-reset 'errno' would still be 'EAGAIN'.
  4. This would create the illusion of an interrupted read. So a new read is tried again, while in reality the socket is closed. This busy loop will continue until 'POLLHUP' is received when we attempt to write back to the client and a 'RST' is received as a response.

Minor Fix

This PR makes proxy_debug_func save/restore the errno value. This can prevent issues of logging influencing error handling.

Extra fixes

  1. Since this PR when a value supplied for an interval is rounded, a warning is printed in error log.
  2. Due to recent changes in the CI this PR packs multiple fixes for issues recently observed within some tests, and some improvements for the tooling.
mirostauder commented 4 months ago

retest this please

mirostauder commented 4 months ago

retest this please

mirostauder commented 4 months ago

retest this please