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 &&