From 7d4f37d25b810ca7984693d229e9cf86ca86dad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 30 Mar 2018 08:35:48 +0300 Subject: [PATCH] MXS-1503: Fix read-only mode regression The master_failure_mode=error_on_write mode was broken due to a faulty assumption that all successfully routed queries would produce a target. This is not the case when a write in error_on_write mode is received. --- .../routing/readwritesplit/rwsplit_route_stmt.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index c663272a6..5bbed8642 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -212,9 +212,14 @@ bool route_single_stmt(RWSplit *inst, RWSplitSession *rses, GWBUF *querybuf, con } } - if (succp && target && prepare_target(rses, target, route_target)) + if (succp && target) { - if (target->session_command_count()) + if (!prepare_target(rses, target, route_target)) + { + // The connection to target was down and we failed to reconnect + succp = false; + } + else if (target->session_command_count()) { // We need to wait until the session commands are executed rses->expected_responses++; @@ -237,10 +242,6 @@ bool route_single_stmt(RWSplit *inst, RWSplitSession *rses, GWBUF *querybuf, con } } } - else - { - succp = false; - } } if (succp && inst->config().connection_keepalive &&