Skip to content

Commit

Permalink
Fix SSL error queue cleanup for backend conns
Browse files Browse the repository at this point in the history
The SSL error queue wasn't cleanup after an SSL related error took place
in a backend connection. This would result in the propagation of the
error to other conns handled by the thread, which could result in:

- Incorrect destruction of connections in conn-pool.
- Invalid error propagation to clients.

This is a consequence of 'libmariadbclient' not performing a cleanup of
this queue by itself. The situation got mitigated since the library
**does** perform a cleanup of such queue during connect phase
('auth_caching_sha2_client|auth_sha256_client'), and ProxySQL does a
cleanup of this queue during frontend SSL traffic.
  • Loading branch information
JavierJF committed Aug 8, 2024
1 parent 01d1fc9 commit f3ea2e6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/MySQL_HostGroups_Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,15 @@ MySQL_Connection * MySQL_HostGroups_Manager::get_MyConn_from_pool(unsigned int _
}

void MySQL_HostGroups_Manager::destroy_MyConn_from_pool(MySQL_Connection *c, bool _lock) {
// 'libmariadbclient' only performs a cleanup of SSL error queue during connect when making use of
// 'auth_caching_sha2_client|auth_sha256_client' during connect. If any SSL errors took place during the
// previous operation, we must cleanup the queue to avoid polluting other backend conns.
int myerr=mysql_errno(c->mysql);
if (myerr >= 2000 && myerr < 3000 && c->mysql->options.use_ssl) {
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 5, "Client error %d detected on SSL connection, cleaning SSL error queue\n", myerr);
ERR_clear_error();
}

bool to_del=true; // the default, legacy behavior
MySrvC *mysrvc=(MySrvC *)c->parent;
if (mysrvc->get_status() == MYSQL_SERVER_STATUS_ONLINE && c->send_quit && queue.size() < __sync_fetch_and_add(&GloMTH->variables.connpoll_reset_queue_length, 0)) {
Expand Down

0 comments on commit f3ea2e6

Please sign in to comment.