From 9689271a3425112b26c359d080bbdade9c49029e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 2 Jan 2018 12:56:50 +0200 Subject: [PATCH] MXS-1541: Use session ID in topfilter The topfilter now uses the session ID as the filename suffix. --- Documentation/Filters/Top-N-Filter.md | 2 +- Documentation/Release-Notes/MaxScale-2.2.1-Release-Notes.md | 5 +++++ server/modules/filter/topfilter/topfilter.c | 5 ++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Documentation/Filters/Top-N-Filter.md b/Documentation/Filters/Top-N-Filter.md index f0eeefcfc..45f1e2dcf 100644 --- a/Documentation/Filters/Top-N-Filter.md +++ b/Documentation/Filters/Top-N-Filter.md @@ -44,7 +44,7 @@ The top filter has one mandatory parameter, `filebase`, and a number of optional ### Filebase -The basename of the output file created for each session. A session index is added to the filename for each file written. This is a mandatory parameter. +The basename of the output file created for each session. The session ID is added to the filename for each file written. This is a mandatory parameter. ``` filebase=/tmp/SqlQueryLog diff --git a/Documentation/Release-Notes/MaxScale-2.2.1-Release-Notes.md b/Documentation/Release-Notes/MaxScale-2.2.1-Release-Notes.md index c9a944d84..f73514682 100644 --- a/Documentation/Release-Notes/MaxScale-2.2.1-Release-Notes.md +++ b/Documentation/Release-Notes/MaxScale-2.2.1-Release-Notes.md @@ -87,6 +87,11 @@ multi-statement or a compound statement modifies the state of the session. This is not a good practice and a change in the client side behavior is advised. +### Top Filter + +The top filter now uses the session ID instead of an internal counter for the +names of the log file names. + ## Dropped Features ## New Features diff --git a/server/modules/filter/topfilter/topfilter.c b/server/modules/filter/topfilter/topfilter.c index 03f598f22..c0e8fd8f8 100644 --- a/server/modules/filter/topfilter/topfilter.c +++ b/server/modules/filter/topfilter/topfilter.c @@ -285,9 +285,8 @@ newSession(MXS_FILTER *instance, MXS_SESSION *session) MXS_FREE(my_session); return NULL; } - sprintf(my_session->filename, "%s.%d", my_instance->filebase, - my_instance->sessions); - atomic_add(&my_instance->sessions, 1); + sprintf(my_session->filename, "%s.%lu", my_instance->filebase, session->ses_id); + my_session->top = (TOPNQ **) MXS_CALLOC(my_instance->topN + 1, sizeof(TOPNQ *)); MXS_ABORT_IF_NULL(my_session->top); for (i = 0; i < my_instance->topN; i++)