MXS-1503: Enable limited session command history

Enabling the session command history but limiting it to a history of 50
commands allows reconnections for sessions that don't change the state too
often.

As pooled connections will exceed this limit quite fast, they are not able
to reconnect to servers once connections are lost. To solve this problem,
the session command history needs a compaction process that removes
redundant history.
This commit is contained in:
Markus Mäkelä 2018-03-28 13:49:38 +03:00
parent dd59e7181c
commit ce853d3f7f
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 35 additions and 6 deletions

View File

@ -10,6 +10,24 @@ report at [Jira](https://jira.mariadb.org).
## Changed Features
### Session Command History
The _readwritesplit_ session command history is now enabled mby default but it
is limited to a total of 50 distict session commands. This default allows most
sessions to leverage the newly improved reconnection mechanism without having to
explicitly enable the history. When the limit of 50 commands is exceeded, the
session command history is disabled. This makes it possible to use pooled
connections by default without having to explicitly disable the history (this
was the case with pre-2.1 versions of MaxScale).
The way that the history is stored has also changed. Instead of storing all
session commands, each session only stores the first and last execution of each
command. This way the history is compressed into a compact representation while
still retaining the relative order of each command.
To keep the old functionality, add `disable_sescmd_history=true` to the service
definition.
## Dropped Features
## New Features

View File

@ -175,15 +175,24 @@ the slave with the least amount of connections
### `max_sescmd_history`
**`max_sescmd_history`** sets a limit on how many session commands each session
can execute before the session command history is disabled. The default is an
unlimited number of session commands.
**`max_sescmd_history`** sets a limit on how many distinct session commands each
session can execute before the session command history is disabled. The default
is 50 session commands.
```
# Set a limit on the session command history
max_sescmd_history=1500
```
The first and last execution of each session command is stored. This means that
with `N` distinct session commands, the minimum value of `max_sescmd_history` to
guarantee that all of them are kept in the history is `N * 2`. In practice, the
real history size required to store the commands is closer to `N`.
If you have long-running sessions which change the session state often, increase
the value of this parameter if server reconnections fail due to disabled session
command history.
When a limitation is set, it effectively creates a cap on the session's memory
consumption. This might be useful if connection pooling is used and the sessions
use large amounts of session commands.
@ -200,7 +209,9 @@ This option is only intended to be enabled if the value of
failed slave to be replaced with a standby slave server.
In versions 2.0 and older, the session command history is enabled by default.
Starting with version 2.1, the session command history is disabled by default.
In version 2.1 and 2.2, the session command history is disabled by default. In
2.3 and newer versions, the session command is enabled but it is limited to a
default of 50 session commands after which the history is disabled.
```
# Disable the session command history

View File

@ -1502,8 +1502,8 @@ MXS_MODULE *MXS_CREATE_MODULE()
{"max_slave_replication_lag", MXS_MODULE_PARAM_INT, "-1"},
{"max_slave_connections", MXS_MODULE_PARAM_STRING, MAX_SLAVE_COUNT},
{"retry_failed_reads", MXS_MODULE_PARAM_BOOL, "true"},
{"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "true"},
{"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "0"},
{"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "false"},
{"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "50"},
{"strict_multi_stmt", MXS_MODULE_PARAM_BOOL, "false"},
{"strict_sp_calls", MXS_MODULE_PARAM_BOOL, "false"},
{"master_accept_reads", MXS_MODULE_PARAM_BOOL, "false"},