Replaying Transactions with MaxScale's Read/Write Split Router
This page is part of MariaDB's Documentation.
The parent of this page is: Read/Write Split Router
Topics on this page:
Overview
The Read/Write Split Router (readwritesplit) routes write queries to the primary server and load balances read-only queries between one or more replica servers. If a server fails, then the router may need to replay in-progress transactions on a different server.
Session Command History
The Read/Write Split Router (readwritesplit) maintains connection state on replica servers by keeping a session command history. If the router has to create a new connection, then it replays these session commands from the previous connection on the new connection.
Minimizing Memory Usage of Session Command History
The session command history can require a lot of memory if connections are long-lived. In these cases, there are two options to limit memory usage:
Configure a maximum size for the session command history
Disable the session command history. This option is not recommended, because you would lose out on the benefits of the session command history.
Configuring Transaction Replay
Configure transaction replay by configuring several parameters for the Read/Write Split Router in
maxscale.cnf
.Parameter
Description
transaction_replay
When this parameter is enabled, transactions will be replayed if they are interrupted. It also implicitly enables the
delayed_retry
andmaster_reconnection
parameters.When this parameter is disabled, interrupted transactions will cause the client connection to be closed.
This parameter is disabled by default.
transaction_replay_max_size
The maximum size of the transaction cache for each client connection. The unit is bytes, but EIC binary prefixes (
Ki
,Mi
,Gi
, andTi
) and SI prefixes (k
,M
,G
, andT
) can also be specified.The default value is 1 MiB.
transaction_replay_attempts
The maximum number of attempts to make when replaying a transaction.
The default value is 5.
transaction_replay_retry_on_deadlock
When this parameter is enabled, transactions will be replayed if a deadlock occurs.
When this parameter is disabled, the client will receive an error if a deadlock occurs.
This parameter is disabled by default.
For example:
[split-router] type = service router = readwritesplit ... transaction_replay = true transaction_replay_max_size = 10Mi transaction_replay_attempts = 10 transaction_replay_retry_on_deadlock = true
Restart the MaxScale instance.
$ sudo systemctl restart maxscale