From 5899556d89289a9649eb1a02638b683482169095 Mon Sep 17 00:00:00 2001 From: Marko Date: Tue, 6 Aug 2019 16:49:11 +0300 Subject: [PATCH 1/2] MXS-2592 Enable runtime configuration of session_trace --- include/maxscale/config.h | 1 + server/core/config.cc | 1 + server/core/config_runtime.cc | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/include/maxscale/config.h b/include/maxscale/config.h index 3fee697ab..337f2e9dd 100644 --- a/include/maxscale/config.h +++ b/include/maxscale/config.h @@ -178,6 +178,7 @@ extern const char CN_SERVER[]; extern const char CN_SERVICES[]; extern const char CN_SERVICE[]; extern const char CN_SESSIONS[]; +extern const char CN_SESSION_TRACE[]; extern const char CN_SESSION_TRACK_TRX_STATE[]; extern const char CN_SKIP_PERMISSION_CHECKS[]; extern const char CN_SOCKET[]; diff --git a/server/core/config.cc b/server/core/config.cc index b55169f31..db9746cca 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -4579,6 +4579,7 @@ json_t* config_maxscale_to_json(const char* host) json_object_set_new(param, CN_RETAIN_LAST_STATEMENTS, json_integer(session_get_retain_last_statements())); json_object_set_new(param, CN_DUMP_LAST_STATEMENTS, json_string(session_get_dump_statements_str())); + json_object_set_new(param, CN_SESSION_TRACE, json_integer(session_get_session_trace())); json_object_set_new(param, CN_LOAD_PERSISTED_CONFIGS, json_boolean(cnf->load_persisted_configs)); json_t* attr = json_object(); diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index a8459fa63..44b55db78 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -1008,6 +1008,23 @@ bool runtime_alter_maxscale(const char* name, const char* value) CN_DUMP_LAST_STATEMENTS); } } + else if (key == CN_SESSION_TRACE) + { + char* endptr; + long intval = strtol(value, &endptr, 10); + + if (*endptr == '\0' && intval >= 0) + { + session_set_session_trace(intval); + mxb_log_set_session_trace(true); + rval = true; + } + else + { + rval = false; + config_runtime_error("Invalid value for '%s': %s", CN_SESSION_TRACE, value); + } + } else if (config_can_modify_at_runtime(key.c_str())) { config_runtime_error("Global parameter '%s' cannot be modified at runtime", name); From 5389e9e252f5e61508794590629f8451a5da0328 Mon Sep 17 00:00:00 2001 From: Marko Date: Wed, 7 Aug 2019 00:18:21 +0300 Subject: [PATCH 2/2] MXS-2592 Add documentation on session_trace --- .../Getting-Started/Configuration-Guide.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index bb95617d8..7e905e9a3 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -912,6 +912,22 @@ Note that you need to specify with `retain_last_statements` how many statements MaxScale should retain for each session. Unless it has been set to another value than `0`, this configuration setting will not have an effect. +### `session_trace` + +How many log entries are stored in the session specific trace log. This log is +written to disk when a session ends abnormally and can be used for debugging +purposes. It would be good to enable this if a session is disconnected and the +log is not detailed enough. In this case the info log might reveal the true +cause of why the connection was closed. + +``` +session_trace=20 +``` +Default is `0`. + +The session trace log is also exposed by REST API and is shown with +`maxctrl show sessions`. + ### `writeq_high_water` High water mark for network write buffer. Controls when network traffic