From ebdb9655e623a615d32cb488da8c9add599b78ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 28 Aug 2020 11:43:39 +0300 Subject: [PATCH 1/2] MXS-3143: Route FOUND_ROWS to last used target This will cause the query to be routed to the same server where a possible SQL_CALC_FOUND_ROWS was executed. --- Documentation/Routers/ReadWriteSplit.md | 13 +++++++++++++ server/core/queryclassifier.cc | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Documentation/Routers/ReadWriteSplit.md b/Documentation/Routers/ReadWriteSplit.md index fa6c76b3f..dea6e575b 100644 --- a/Documentation/Routers/ReadWriteSplit.md +++ b/Documentation/Routers/ReadWriteSplit.md @@ -643,3 +643,16 @@ executed session command for the duration of the session. Applications that use long-running sessions might cause MariaDB MaxScale to consume a growing amount of memory unless the sessions are closed. This can be solved by adjusting the value of `max_sescmd_history`. + +### Routing to previous target + +In the following cases, a query is routed to the same server where the previous +query was executed. If no previous target is found, the query is routed to the +current master. + +* If a query uses the `FOUND_ROWS()` function, it will be routed to the server + where the last query was executed. This is done with the assumption that a + query with `SQL_CALC_FOUND_ROWS` was previously executed. + +* COM_STMT_FETCH_ROWS will always be routed to the same server where the + COM_STMT_EXECUTE was routed. diff --git a/server/core/queryclassifier.cc b/server/core/queryclassifier.cc index 38b83d5ce..879ea5894 100644 --- a/server/core/queryclassifier.cc +++ b/server/core/queryclassifier.cc @@ -1107,6 +1107,21 @@ QueryClassifier::RouteInfo QueryClassifier::update_route_info( process_routing_hints(pBuffer->hint, &route_target); + if (route_target == TARGET_SLAVE) + { + const QC_FUNCTION_INFO* infos = nullptr; + size_t n_infos = 0; + qc_get_function_info(pBuffer, &infos, &n_infos); + + for (size_t i = 0; i < n_infos; ++i) + { + if (strcasecmp(infos[i].name, "FOUND_ROWS") == 0) + { + route_target = TARGET_LAST_USED; + } + } + } + if (session_trx_is_ending(m_pSession) || qc_query_is_type(type_mask, QUERY_TYPE_BEGIN_TRX)) { From 63a050bd7a649d231ce2e86d2cdad31ce6343dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 28 Aug 2020 12:16:17 +0300 Subject: [PATCH 2/2] MXS-3051: Show connection TLS cipher This tells the user whether a session is using TLS or not. Currently, only the client TLS cipher is shown in MaxCtrl as the backend ciphers require additional formatting. --- maxctrl/lib/show.js | 5 +++++ server/core/dcb.cc | 11 ++++++++++- server/core/session.cc | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/maxctrl/lib/show.js b/maxctrl/lib/show.js index f230b494b..e39f37a94 100644 --- a/maxctrl/lib/show.js +++ b/maxctrl/lib/show.js @@ -208,6 +208,11 @@ const session_fields = [ path: 'attributes.idle', description: 'How long the session has been idle, in seconds' }, + { + name: 'Client TLS Cipher', + path: 'attributes.client.cipher', + description: 'Client TLS cipher' + }, { name: 'Connections', path: 'attributes.connections[].server', diff --git a/server/core/dcb.cc b/server/core/dcb.cc index 747ea7d83..bdd7319e6 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -3866,7 +3866,16 @@ json_t* dcb_to_json(DCB* dcb) char buf[25]; snprintf(buf, sizeof(buf), "%p", dcb); json_object_set_new(obj, "id", json_string(buf)); - json_object_set_new(obj, "server", json_string(dcb->server->name)); + + if (dcb->server) + { + json_object_set_new(obj, "server", json_string(dcb->server->name)); + } + + if (dcb->ssl) + { + json_object_set_new(obj, "cipher", json_string(SSL_get_cipher_name(dcb->ssl))); + } if (dcb->func.diagnostics_json) { diff --git a/server/core/session.cc b/server/core/session.cc index 5daae465c..677cc94ec 100644 --- a/server/core/session.cc +++ b/server/core/session.cc @@ -876,6 +876,7 @@ json_t* session_json_data(const Session* session, const char* host) } json_object_set_new(attr, "connections", dcb_arr); + json_object_set_new(attr, "client", dcb_to_json(session->client_dcb)); json_t* queries = session->queries_as_json(); json_object_set_new(attr, "queries", queries);