MXS-2295: Reset session commands on connection reset

When the connection state is reset by executing a COM_CHANGE_USER or
COM_RESET_CONNECTION, readwritesplit does not need to store the session
command history that was executed before it. With this, pooled connections
will effectively behave like normal connections if the pooling mechanism
is smart enough to reset the connection. This also prevents unwanted
visibility into the session states of other connections.
This commit is contained in:
Markus Mäkelä 2019-01-28 11:52:21 +02:00
parent 24c9b62a2f
commit 2e809524d1
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 17 additions and 1 deletions

View File

@ -299,8 +299,11 @@ typedef enum
MXS_COM_STMT_RESET = 26,
MXS_COM_SET_OPTION = 27,
MXS_COM_STMT_FETCH = 28,
MXS_COM_DAEMON = 29,
MXS_COM_UNSUPPORTED = 30,
MXS_COM_RESET_CONNECTION = 31,
MXS_COM_STMT_BULK_EXECUTE = 0xfa,
MXS_COM_DAEMON,
MXS_COM_MULTI = 0xfe,
MXS_COM_END
} mxs_mysql_cmd_t;

View File

@ -161,5 +161,18 @@ void RWSplitSession::process_sescmd_response(SRWBackend& backend, GWBUF** ppPack
gwbuf_free(*ppPacket);
*ppPacket = NULL;
}
if (m_expected_responses == 0
&& (command == MXS_COM_CHANGE_USER || command == MXS_COM_RESET_CONNECTION))
{
// This is the last session command to finish that resets the session state, reset the history
MXS_INFO("Resetting session command history (length: %lu)", m_sescmd_list.size());
m_sescmd_list.clear();
m_sescmd_responses.clear();
m_slave_responses.clear();
m_recv_sescmd = 0;
m_sent_sescmd = 0;
m_sescmd_count = 1;
}
}
}