From 21bb341c7d67f9752847ddcd4fb917568169230e Mon Sep 17 00:00:00 2001 From: VilhoRaatikka Date: Tue, 27 Jan 2015 15:21:31 +0200 Subject: [PATCH] Fix to bug #507, http://bugs.mariadb.com/show_bug.cgi?id=507 readwritesplit.c:get_route_target routed query to slave although query type was combined QUERY_TYPE_READ | QUERY_TYPE_MASTER_READ, where the latter is supposed to be routed to master. --- server/core/service.c | 1 + server/modules/routing/readwritesplit/readwritesplit.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/core/service.c b/server/core/service.c index 1bfa80177..8432898b0 100644 --- a/server/core/service.c +++ b/server/core/service.c @@ -980,6 +980,7 @@ SERVICE *ptr; } while (ptr) { + ss_dassert(ptr->stats.n_current >= 0); dcb_printf(dcb, "%-25s | %-20s | %6d | %5d\n", ptr->name, ptr->routerModule, ptr->stats.n_current, ptr->stats.n_sessions); diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index 1f5c77bab..5912d1301 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -1402,7 +1402,8 @@ static route_target_t get_route_target ( QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_READ))) /*< read global sys var */ { /** First set expected targets before evaluating hints */ - if (QUERY_IS_TYPE(qtype, QUERY_TYPE_READ) || + if (!QUERY_IS_TYPE(qtype, QUERY_TYPE_MASTER_READ) && + QUERY_IS_TYPE(qtype, QUERY_TYPE_READ) || QUERY_IS_TYPE(qtype, QUERY_TYPE_SHOW_TABLES) || /*< 'SHOW TABLES' */ /** Configured to allow reading variables from slaves */ (use_sql_variables_in == TYPE_ALL && @@ -1412,7 +1413,8 @@ static route_target_t get_route_target ( { target = TARGET_SLAVE; } - else if (QUERY_IS_TYPE(qtype, QUERY_TYPE_EXEC_STMT) || + else if (QUERY_IS_TYPE(qtype, QUERY_TYPE_MASTER_READ) || + QUERY_IS_TYPE(qtype, QUERY_TYPE_EXEC_STMT) || /** Configured not to allow reading variables from slaves */ (use_sql_variables_in == TYPE_MASTER && (QUERY_IS_TYPE(qtype, QUERY_TYPE_USERVAR_READ) ||