From 36b10d3f05380390b822ac51ac7a051084896415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sat, 31 Mar 2018 17:43:46 +0300 Subject: [PATCH] MXS-1502: Log session command warning only once The warning that tells the user that the session command history has been exceeded is now only logged once. This is to prevent the message from being repeatedly logged when the default value is not large enough. Also fixed the session_limits test to use distinct session commands. This way the session command history compaction is not in effect and the test again tests the correct thing. --- maxscale-system-test/session_limits.cpp | 4 ++-- .../routing/readwritesplit/rwsplit_route_stmt.cc | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/maxscale-system-test/session_limits.cpp b/maxscale-system-test/session_limits.cpp index c162db948..84c75972a 100644 --- a/maxscale-system-test/session_limits.cpp +++ b/maxscale-system-test/session_limits.cpp @@ -40,11 +40,11 @@ int main(int argc, char *argv[]) test.maxscales->connect_maxscale(0); for (int i = 0; i < 10; i++) { - test.try_query(test.maxscales->conn_rwsplit[0], "set @test=1"); + test.try_query(test.maxscales->conn_rwsplit[0], std::string("set @test=" + std::to_string(i)).c_str()); } test.tprintf("Execute one more session command and expect message in error log"); - execute_query(test.maxscales->conn_rwsplit[0], "set @test=1"); + execute_query(test.maxscales->conn_rwsplit[0], "set @test=11"); sleep(1); test.check_log_err(0, "Router session exceeded session command history limit", true); test.maxscales->close_maxscale_connections(0); diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index 78a5a9445..65727dc0c 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -379,10 +379,15 @@ bool route_session_write(RWSplitSession *rses, GWBUF *querybuf, if (rses->rses_config.max_sescmd_history > 0 && rses->sescmd_list.size() >= rses->rses_config.max_sescmd_history) { - MXS_WARNING("Router session exceeded session command history limit. " - "Slave recovery is disabled and only slave servers with " - "consistent session state are used " - "for the duration of the session."); + static bool warn_history_exceeded = true; + if (warn_history_exceeded) + { + MXS_WARNING("Router session exceeded session command history limit. Slave " + "recovery is disabled and only slave servers with consistent " + "session state are used for the duration of the session."); + warn_history_exceeded = false; + } + rses->rses_config.disable_sescmd_history = true; rses->rses_config.max_sescmd_history = 0; rses->sescmd_list.clear();