From cb878f18b7e4d0af1dd9c10afb8b757bcadb2d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 28 Nov 2018 10:23:48 +0200 Subject: [PATCH 1/3] Update max_slave_connections documentation Corrected the default value and added a more detailed explanation of what the parameter does and how it affects client connections. --- Documentation/Routers/ReadWriteSplit.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Documentation/Routers/ReadWriteSplit.md b/Documentation/Routers/ReadWriteSplit.md index adfdca5b7..abd69f93a 100644 --- a/Documentation/Routers/ReadWriteSplit.md +++ b/Documentation/Routers/ReadWriteSplit.md @@ -34,9 +34,28 @@ For more details about the standard service parameters, refer to the ### `max_slave_connections` **`max_slave_connections`** sets the maximum number of slaves a router session -uses at any moment. The default is to use all available slaves. +uses at any moment. The default is to use at most 255 slave connections per +client connection. In older versions the default was to use all available slaves +with no limit. - max_slave_connections= +``` +max_slave_connections= +``` + +For example, if you have configured MaxScale with one master and three slaves +and set `max_slave_connections=2`, for each client connection a connection to +the master and two slave connections would be opened. The read query load +balancing is then done between these two slaves and writes are sent to the +master. + +By tuning this parameter, you can control how dynamic the load balancing is at +the cost of extra created connections. With a lower value of +`max_slave_connections`, less connections per session are created and the set of +possible slave servers is smaller. With a higher value in +`max_slave_connections`, more connections are created which requires more +resources but load balancing will almost always give the best single query +response time and performance. Longer sessions are less affected by a high +`max_slave_connections` as the relative cost of opening a connection is lower. ### `max_slave_replication_lag` From 964180804c039677023dfb4e1961ebf0403c659e Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 3 Dec 2018 15:59:43 +0200 Subject: [PATCH 2/3] MXS-2207 Add test that reveals problem With qc_mysqlembedded statements like SET STATEMENT ... FOR stmt; are always classified as READ, although their type should be that of stmt. --- query_classifier/test/maxscale.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/query_classifier/test/maxscale.test b/query_classifier/test/maxscale.test index d18717b5f..bb9cdf905 100644 --- a/query_classifier/test/maxscale.test +++ b/query_classifier/test/maxscale.test @@ -112,3 +112,6 @@ SET STATEMENT max_statement_time=30 FOR SELECT seq FROM seq_0_to_100000; # MXS-1935 PREPARE a FROM @sql; + +# MXS-2207 +SET STATEMENT max_statement_time=30 FOR UPDATE tbl SET a = 42; From 87d2a45b203880d0c255468385a7597e4797f03b Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 3 Dec 2018 16:03:51 +0200 Subject: [PATCH 3/3] MXS-2207 Fix the problem in qc_mysqlembedded --- query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc index af7d5dbef..fcc882e2b 100644 --- a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc +++ b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc @@ -827,6 +827,7 @@ static uint32_t resolve_query_type(parsing_info_t *pi, THD* thd) } else if (lex->option_type == OPT_SESSION) { + bool do_return = true; /** * SHOW syntax http://dev.mysql.com/doc/refman/5.6/en/show.html */ @@ -870,10 +871,16 @@ static uint32_t resolve_query_type(parsing_info_t *pi, THD* thd) } else { - type |= QUERY_TYPE_READ; + // This will cause the type of a statement like + // "SET STATEMENT ... FOR XYZ" to be the type + // of XYZ. + do_return = false; } - goto return_qtype; + if (do_return) + { + goto return_qtype; + } } /**