Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MXS-4090: Add failsafe for unexpected responses
If the backend protocol itself is broken, as is seen in MXS-4090, an
unexpected response can still end up being routed to the routers. To
handle the cases where an unexpected result will cause a crash, we need
code in readwritesplit that kills the session if it was't expecting a
result. This should prevent the crash while also allowing better debug
information to be generated in the hopes that it will eventually be
fixed.
  • Loading branch information
markus456 committed Jun 7, 2022
1 parent 2b1a894 commit 8f9be9e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/maxscale/backend.hh
Expand Up @@ -161,6 +161,16 @@ public:
return !m_responses.empty() && m_responses.front() == IGNORE_RESPONSE;
}

/**
* @brief Check if a response is unexpected
*
* @return True if the result was not expected
*/
bool unexpected_response() const
{
return m_responses.empty();
}

/**
* @brief Check if the backend is closed
*
Expand Down
12 changes: 12 additions & 0 deletions server/modules/routing/readwritesplit/rwsplitsession.cc
Expand Up @@ -542,6 +542,18 @@ bool RWSplitSession::clientReply(GWBUF* writebuf, const mxs::ReplyRoute& down, c

if (reply.is_complete())
{
if (backend->unexpected_response())
{
MXS_ERROR("Unexpected response from '%s', closing session: %s",
backend->name(), reply.describe().c_str());
m_pSession->dump_statements();
m_pSession->dump_session_log();
m_pSession->kill();
gwbuf_free(writebuf);
mxb_assert(!true);
return false;
}

bool ignore_response = backend->should_ignore_response();

if (ignore_response)
Expand Down

0 comments on commit 8f9be9e

Please sign in to comment.