From aea64aede280558ca6b55500dfa7eb049ec9c377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Feb 2019 10:51:05 +0200 Subject: [PATCH] Prune only when history size is exceeded The documentation stated that at most `max_sescmd_history` commands were kept but in reality the number of commands kept in the history was one command smaller than what was documented. --- server/modules/routing/readwritesplit/rwsplit_route_stmt.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index 87ae8192e..4f24c7e70 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -517,7 +517,8 @@ bool RWSplitSession::route_session_write(GWBUF* querybuf, uint8_t command, uint3 } } - if (m_config.max_sescmd_history > 0 && m_sescmd_list.size() >= m_config.max_sescmd_history) + if (m_config.max_sescmd_history > 0 && m_sescmd_list.size() >= m_config.max_sescmd_history + && !m_config.prune_sescmd_history) { static bool warn_history_exceeded = true; if (warn_history_exceeded) @@ -540,7 +541,7 @@ bool RWSplitSession::route_session_write(GWBUF* querybuf, uint8_t command, uint3 } if (m_config.prune_sescmd_history && !m_sescmd_list.empty() - && m_sescmd_list.size() + 1 >= m_config.max_sescmd_history) + && m_sescmd_list.size() >= m_config.max_sescmd_history) { // Close to the history limit, remove the oldest command prune_to_position(m_sescmd_list.front()->get_position());