mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MDEV-33616 workaround libmariadb bug : mysql_errno = 0 on failed connection
The bug can happens on macOS, if server closes the socket without sending error packet to client. Closing the socket on server side is legitimate, and happen e.g when write timeout occurs, perhaps also other situations. However mysqltest is not prepared to handle mysql_errno 0, and erroneously thinks connection was successfully established. The fix/workaround in mysqltest is to treat client failure with mysql_errno 0 the same as CR_SERVER_LOST (generic client-side communication error) The real fix in client library would ensure that mysql_errno is set on errors.
This commit is contained in:
parent
d524cb5b3d
commit
f2eda61579
1 changed files with 12 additions and 6 deletions
|
@ -5908,14 +5908,20 @@ int connect_n_handle_errors(struct st_command *command,
|
|||
stay clear of trying to work out which exact user-limit was
|
||||
exceeded.
|
||||
*/
|
||||
auto my_err= mysql_errno(con);
|
||||
if(my_err == 0)
|
||||
{
|
||||
/* Workaround client library bug, not indicating connection error. */
|
||||
my_err= CR_SERVER_LOST;
|
||||
}
|
||||
|
||||
if (((mysql_errno(con) == ER_TOO_MANY_USER_CONNECTIONS) ||
|
||||
(mysql_errno(con) == ER_USER_LIMIT_REACHED)) &&
|
||||
if (((my_err == ER_TOO_MANY_USER_CONNECTIONS) ||
|
||||
(my_err == ER_USER_LIMIT_REACHED)) &&
|
||||
(failed_attempts++ < opt_max_connect_retries))
|
||||
{
|
||||
int i;
|
||||
|
||||
i= match_expected_error(command, mysql_errno(con), mysql_sqlstate(con));
|
||||
i= match_expected_error(command, my_err, mysql_sqlstate(con));
|
||||
|
||||
if (i >= 0)
|
||||
goto do_handle_error; /* expected error, handle */
|
||||
|
@ -5925,9 +5931,9 @@ int connect_n_handle_errors(struct st_command *command,
|
|||
}
|
||||
|
||||
do_handle_error:
|
||||
var_set_errno(mysql_errno(con));
|
||||
handle_error(command, mysql_errno(con), mysql_error(con),
|
||||
mysql_sqlstate(con), ds);
|
||||
var_set_errno(my_err);
|
||||
handle_error(command, my_err, mysql_error(con),
|
||||
mysql_sqlstate(con), ds);
|
||||
return 0; /* Not connected */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue