MXS-2213: Clear stored PS information

The information stored for each prepared statement would not be cleared
until the end of the session. This is a problem if the sessions last for a
very long time as the stored information is unused once a COM_STMT_CLOSE
has been received.

In addition to this, the session command response maps were not cleared
correctly if all backends had processed all session commands.
This commit is contained in:
Markus Mäkelä 2018-12-08 00:58:46 +02:00 committed by Johan Wikman
parent 8b00a00ea7
commit 48efa6d027
2 changed files with 18 additions and 0 deletions

View File

@ -202,6 +202,15 @@ bool route_single_stmt(RWSplit *inst, RWSplitSession *rses, GWBUF *querybuf, con
if (not_locked_to_master && is_ps_command(command))
{
if (command == MXS_COM_STMT_CLOSE)
{
// Remove the command from the PS mapping
ss_dassert(TARGET_IS_ALL(route_target));
rses->ps_manager.erase(stmt_id);
rses->ps_handles.erase(mxs_mysql_extract_ps_id(querybuf));
rses->exec_map.erase(stmt_id);
}
/** Replace the client statement ID with our internal one only if the
* target node is not the current master */
replace_binary_ps_id(querybuf, stmt_id);
@ -422,6 +431,11 @@ bool route_session_write(RWSplitSession *rses, GWBUF *querybuf,
{
rses->sescmd_responses.erase(rses->sescmd_responses.begin(), it);
}
else
{
// All responses processed
rses->sescmd_responses.clear();
}
}
else
{

View File

@ -86,6 +86,10 @@ bool RWBackend::write(GWBUF* buffer, response_type type)
// Any non-zero flag value means that we have an open cursor
m_opening_cursor = flags != 0;
}
else if (cmd == MXS_COM_STMT_CLOSE)
{
m_ps_handles.erase(it);
}
else if (cmd == MXS_COM_STMT_FETCH)
{
// Number of rows to fetch is a 4 byte integer after the ID