From 09dc92973e7149174ffe9923f9fe0ce0e5bc28f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 14 Mar 2019 09:25:25 +0200 Subject: [PATCH] Discard connections as the last step Th discarding of connections in maintenance mode must be done after any results have been written to them. This prevents closing of the connection before the actual result is returned. --- .../routing/readwritesplit/rwsplitsession.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/modules/routing/readwritesplit/rwsplitsession.cc b/server/modules/routing/readwritesplit/rwsplitsession.cc index 8cb24701b..f9e171c21 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.cc +++ b/server/modules/routing/readwritesplit/rwsplitsession.cc @@ -740,15 +740,6 @@ void RWSplitSession::clientReply(GWBUF* writebuf, DCB* backend_dcb) m_can_replay_trx = true; } - if (m_expected_responses == 0) - { - /** - * Close stale connections to servers in maintenance. Done here to avoid closing the connections - * before all responses have been received. - */ - close_stale_connections(); - } - if (backend->in_use() && backend->has_session_commands()) { // Backend is still in use and has more session commands to execute @@ -775,6 +766,15 @@ void RWSplitSession::clientReply(GWBUF* writebuf, DCB* backend_dcb) /** Write reply to client DCB */ MXS_SESSION_ROUTE_REPLY(backend_dcb->session, writebuf); } + + if (m_expected_responses == 0) + { + /** + * Close stale connections to servers in maintenance. Done here to avoid closing the connections + * before all responses have been received. + */ + close_stale_connections(); + } } void check_and_log_backend_state(const SRWBackend& backend, DCB* problem_dcb)