Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markus456 committed Dec 7, 2018
1 parent ee38cdc commit 39b5566
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server/modules/routing/readwritesplit/rwsplit_route_stmt.cc
Expand Up @@ -202,6 +202,13 @@ 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
rses->ps_manager.erase(stmt_id);
rses->ps_handles.erase(mxs_mysql_extract_ps_id(querybuf));
}

/** 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);
Expand Down Expand Up @@ -422,6 +429,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
{
Expand Down
4 changes: 4 additions & 0 deletions server/modules/routing/readwritesplit/rwsplitsession.cc
Expand Up @@ -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
Expand Down

0 comments on commit 39b5566

Please sign in to comment.