From be7344f747361a31f031435130b82534c8e6c640 Mon Sep 17 00:00:00 2001 From: MassimilianoPinto Date: Wed, 25 Jan 2017 12:58:10 +0100 Subject: [PATCH] MXS-185: "read-only" transactions detected in readwritesplit handleError handleError can detect READ ONLY transaction set when problem_dcb == rses->forced_node->bref_dcb. Session will be closed and rses->forced_node set to NULL --- .../routing/readwritesplit/readwritesplit.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index be03452cb..86533f999 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -1437,6 +1437,23 @@ static void handleError(ROUTER *instance, void *router_session, } else if (bref) { + /** Check whether problem_dcb is same as dcb of rses->forced_node + * and within READ ONLY transaction: + * if true reset rses->forced_node and close session + */ + if (rses->forced_node && + (rses->forced_node->bref_dcb == problem_dcb && + session_trx_is_read_only(problem_dcb->session))) + { + MXS_ERROR("forced_node SLAVE %s in opened READ ONLY transaction has failed:" + " closing session", + problem_dcb->server->unique_name); + + rses->forced_node == NULL; + *succp = false; + break; + } + /** We should reconnect only if we find a backend for this * DCB. If this DCB is an older DCB that has been closed, * we can ignore it. */