From 3b6387c95258eb1fffacf5669ac6411c3cc96eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 27 Jun 2019 23:18:33 +0300 Subject: [PATCH] MXS-2562: Stop immediately on mid-resultset failure If a server fails mid-resultset, there's not a lot we can do to recover the situation. A few cases could be handled (e.g. generate an ERR if the resultset has proceeded to the row processing stage) but these fall outside the scope of the original issue. --- include/maxscale/protocol/rwbackend.hh | 10 ++++++++++ .../modules/routing/readwritesplit/rwsplitsession.cc | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/maxscale/protocol/rwbackend.hh b/include/maxscale/protocol/rwbackend.hh index bbf8f0c2a..cb89d855d 100644 --- a/include/maxscale/protocol/rwbackend.hh +++ b/include/maxscale/protocol/rwbackend.hh @@ -141,6 +141,16 @@ public: return m_reply_state == REPLY_STATE_DONE; } + /** + * Check if a partial response has been received from the backend + * + * @return True if some parts of the reply have been received + */ + bool reply_has_started() const + { + return m_reply_state != REPLY_STATE_START && m_reply_state != REPLY_STATE_DONE; + } + void process_packets(GWBUF* buffer); void process_reply_start(mxs::Buffer::iterator it); diff --git a/server/modules/routing/readwritesplit/rwsplitsession.cc b/server/modules/routing/readwritesplit/rwsplitsession.cc index b9259df2d..bbdb45297 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.cc +++ b/server/modules/routing/readwritesplit/rwsplitsession.cc @@ -947,6 +947,18 @@ void RWSplitSession::handleError(GWBUF* errmsgbuf, SRWBackend& backend = get_backend_from_dcb(problem_dcb); mxb_assert(backend->in_use()); + if (backend->reply_has_started()) + { + MXS_ERROR("Server '%s' was lost in the middle of a resultset, cannot continue the session: %s", + backend->name(), extract_error(errmsgbuf).c_str()); + + // This effectively causes an instant termination of the client connection and prevents any errors + // from being sent to the client (MXS-2562). + dcb_close(m_client); + *succp = true; + return; + } + switch (action) { case ERRACT_NEW_CONNECTION: