From 3999bed3e28dbdba9f00ea80b8ac5f52ce1d8199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 14 Mar 2018 08:23:38 +0200 Subject: [PATCH] MXS-359: Reset temporary table tracking on master change When the master changes mid-session, the temporary tables are inevitably lost. This could be avoided by routing temporary table creation to all servers. --- .../routing/readwritesplit/rwsplit_route_stmt.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index 9a2b5e7b1..87940cdca 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -1079,6 +1079,15 @@ bool should_replace_master(RWSplitSession *rses, SRWBackend& target) !locked_to_master(rses); } +void replace_master(RWSplitSession *rses, SRWBackend& target) +{ + rses->current_master = target; + + // As the master has changed, we can reset the temporary table information + rses->have_tmp_tables = false; + rses->temp_tables.clear(); +} + /** * @brief Handle master is the target * @@ -1100,7 +1109,7 @@ bool handle_master_is_target(RWSplit *inst, RWSplitSession *rses, { MXS_INFO("Replacing old master '%s' with new master '%s'", rses->current_master ? rses->current_master->name() : "", target->name()); - rses->current_master = target; + replace_master(rses, target); } if (target && target == rses->current_master)