MXS-2834: Make retrying of trx deadlocks configurable
The behavior is not desirable in all cases and should be enabled only if needed.
This commit is contained in:
@ -537,6 +537,19 @@ controls how many server and network failures a single transaction replay
|
|||||||
tolerates. If a transaction is replayed successfully, the counter for failed
|
tolerates. If a transaction is replayed successfully, the counter for failed
|
||||||
attempts is reset.
|
attempts is reset.
|
||||||
|
|
||||||
|
### `transaction_replay_retry_on_deadlock`
|
||||||
|
|
||||||
|
Enable automatic retrying of transactions that end up in a deadlock. This
|
||||||
|
parameter was added in MaxScale 2.4.6 and the feature is disabled by
|
||||||
|
default. MaxScale versions from 2.4.0 to 2.4.5 always tried to replay deadlocked
|
||||||
|
transactions.
|
||||||
|
|
||||||
|
If this feature is enabled and a transaction returns a deadlock error
|
||||||
|
(e.g. `SQLSTATE 40001: Deadlock found when trying to get lock; try restarting transaction`),
|
||||||
|
the transaction is automatically retried. If the retrying of the transaction
|
||||||
|
results in another deadlock error, it is retried until it either succeeds or a
|
||||||
|
transaction checksum error is encountered.
|
||||||
|
|
||||||
### `optimistic_trx`
|
### `optimistic_trx`
|
||||||
|
|
||||||
Enable optimistic transaction execution. This parameter controls whether normal
|
Enable optimistic transaction execution. This parameter controls whether normal
|
||||||
|
@ -520,6 +520,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
{"transaction_replay", MXS_MODULE_PARAM_BOOL, "false"},
|
{"transaction_replay", MXS_MODULE_PARAM_BOOL, "false"},
|
||||||
{"transaction_replay_max_size",MXS_MODULE_PARAM_SIZE, "1Mi"},
|
{"transaction_replay_max_size",MXS_MODULE_PARAM_SIZE, "1Mi"},
|
||||||
{"transaction_replay_attempts",MXS_MODULE_PARAM_COUNT, "5"},
|
{"transaction_replay_attempts",MXS_MODULE_PARAM_COUNT, "5"},
|
||||||
|
{"transaction_replay_retry_on_deadlock",MXS_MODULE_PARAM_BOOL, "false"},
|
||||||
{"optimistic_trx", MXS_MODULE_PARAM_BOOL, "false"},
|
{"optimistic_trx", MXS_MODULE_PARAM_BOOL, "false"},
|
||||||
{"lazy_connect", MXS_MODULE_PARAM_BOOL, "false"},
|
{"lazy_connect", MXS_MODULE_PARAM_BOOL, "false"},
|
||||||
{MXS_END_MODULE_PARAMS}
|
{MXS_END_MODULE_PARAMS}
|
||||||
|
@ -161,6 +161,7 @@ struct Config
|
|||||||
, transaction_replay(params->get_bool("transaction_replay"))
|
, transaction_replay(params->get_bool("transaction_replay"))
|
||||||
, trx_max_size(params->get_size("transaction_replay_max_size"))
|
, trx_max_size(params->get_size("transaction_replay_max_size"))
|
||||||
, trx_max_attempts(params->get_integer("transaction_replay_attempts"))
|
, trx_max_attempts(params->get_integer("transaction_replay_attempts"))
|
||||||
|
, trx_retry_on_deadlock(params->get_bool("transaction_replay_retry_on_deadlock"))
|
||||||
, optimistic_trx(params->get_bool("optimistic_trx"))
|
, optimistic_trx(params->get_bool("optimistic_trx"))
|
||||||
, lazy_connect(params->get_bool("lazy_connect"))
|
, lazy_connect(params->get_bool("lazy_connect"))
|
||||||
{
|
{
|
||||||
@ -225,6 +226,7 @@ struct Config
|
|||||||
bool transaction_replay; /**< Replay failed transactions */
|
bool transaction_replay; /**< Replay failed transactions */
|
||||||
size_t trx_max_size; /**< Max transaction size for replaying */
|
size_t trx_max_size; /**< Max transaction size for replaying */
|
||||||
int64_t trx_max_attempts; /**< Maximum number of transaction replay attempts */
|
int64_t trx_max_attempts; /**< Maximum number of transaction replay attempts */
|
||||||
|
bool trx_retry_on_deadlock; /**< Replay the transaction if it ends up in a deadlock */
|
||||||
bool optimistic_trx; /**< Enable optimistic transactions */
|
bool optimistic_trx; /**< Enable optimistic transactions */
|
||||||
bool lazy_connect; /**< Create connections only when needed */
|
bool lazy_connect; /**< Create connections only when needed */
|
||||||
};
|
};
|
||||||
|
@ -709,7 +709,8 @@ void RWSplitSession::clientReply(GWBUF* writebuf, DCB* backend_dcb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((error.is_rollback() || error.is_wsrep_error()) && handle_ignorable_error(backend))
|
if (((m_config.trx_retry_on_deadlock && error.is_rollback()) || error.is_wsrep_error())
|
||||||
|
&& handle_ignorable_error(backend))
|
||||||
{
|
{
|
||||||
// We can ignore this error and treat it as if the connection to the server was broken.
|
// We can ignore this error and treat it as if the connection to the server was broken.
|
||||||
gwbuf_free(writebuf);
|
gwbuf_free(writebuf);
|
||||||
|
Reference in New Issue
Block a user