Skip to content

Commit

Permalink
Fix 'test_backend_conn_ping-t' conn-pool cleanup
Browse files Browse the repository at this point in the history
Since the test stress test the connection pool, verifying the limits of
backend connections that ProxySQL can maintain, it's possible to
propagate a connection pool filled with idle connections to the next
tests. This could lead to connection exhaustion on those tests. The
scenario could be prevented in a generic way, as part of the
reconfiguration between tests. It's left as a potential 'TODO' in the
test itself.
  • Loading branch information
JavierJF committed Jun 17, 2024
1 parent 9470923 commit b6e9293
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/tap/tests/test_backend_conn_ping-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,29 @@ int main(int, char**) {
diag("'check_backend_conns()' failed for servers: '%s'", nlohmann::json(m_server_test).dump().c_str());
}

// NOTE-TODO: We are required to recover the connection pool to an usable status for subsequent tests.
// This could be done giving sensible values to `mysql-free_connections_pct`, for keeping always a good
// number of connections below the max server threshold, and `mysql-ping_interval_server_msec`, ensuring
// that after the test is finished, those idle connections would be release till reaching
// `free_connections_pct`. These conditions are not ensured right now.
{
diag("Connection pool cleanup before test exit");
MYSQL_QUERY_T(admin, "UPDATE mysql_servers SET max_connections=0");
MYSQL_QUERY_T(admin, "LOAD MYSQL SERVERS TO RUNTIME");

diag("Waiting for connection cleanup on ProxySQL...");
w_res = wait_target_backend_conns(admin, 0, 10);
if (w_res != EXIT_SUCCESS) {
string err_msg {};
if (w_res == -2) {
err_msg = "'wait_target_backend_conns()' timed out";
} else {
err_msg = "'wait_target_backend_conns()' failed";
}
fprintf(stderr, "File %s, line %d, Error: \"%s\"\n", __FILE__, __LINE__, err_msg.c_str());
}
}

diag("Restoring previous 'MySQL' servers infra config...");

{
Expand Down

0 comments on commit b6e9293

Please sign in to comment.