[MXS-4515] MaxScale leaks sessions if they are closed when writeq throttling is enabled Created: 2023-02-17  Updated: 2023-02-21  Resolved: 2023-02-20

Status: Closed
Project: MariaDB MaxScale
Component/s: Core
Affects Version/s: 2.5.24, 6.4.5, 22.08.4
Fix Version/s: 2.5.25, 6.4.6, 22.08.5

Type: Bug Priority: Major
Reporter: markus makela Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None


 Description   

The following Connector-J test case reproduces the problem. It only happens if writeq_high_water is lower than max_allowed_packet on the server. Due to the recent changes to the default values, this is unlikely to happen in older versions if the default values are used.

-Dtest=integration.PreparedStatementParametersTest#bigSendError

A workaround to this is to use the old default value for writeq_high_water. It won't eliminate the problem but it helps reduce the likelihood of it happening. Disabling the writeq throttling completely will prevent it but that can cause extreme memory usage.



 Comments   
Comment by markus makela [ 2023-02-18 ]

Here's an example test program that reproduces the problem:

#include "common.hh"
 
int main(int argc, char** argv)
{
    Config cnf = parse(argc, argv);
    MYSQL* c = mysql_init(nullptr);
 
    std::string query = "SELECT '";
    query += std::string(15.5 * 1024.0 * 1024.0, 'a');
    query += "'";
 
    if (!mysql_real_connect(c, cnf.host, cnf.user, cnf.password, cnf.db, cnf.port, nullptr, CLIENT_MULTI_STATEMENTS|CLIENT_MULTI_RESULTS))
    {
        std::cout << "Connect: " << mysql_error(c) << std::endl;
    }
    else
    {
        if (mysql_send_query(c, query.c_str(), query.size()))
        {
            std::cout << "mysql_send_query: " << mysql_error(c) << std::endl;
        }
 
        _Exit(0);
    }
 
    return 0;
}

If the kernel is configured to use very small network write buffers or 2.5 is patched to tune them down (i.e. SO_SNDBUF set to 1024), the following assertion is hit in dcb.cc:

bool DCB::enable_events()
{
    mxb_assert(m_state == State::CREATED || m_state == State::NOPOLLING);

It turns out that this is a bug that was fixed for 22.08 but also needs to be fixed for 2.5.

Generated at Thu Feb 08 04:29:12 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.