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:
Markus Mäkelä
2020-01-11 11:53:01 +02:00
parent 09c55111cc
commit 6c14ac7829
4 changed files with 18 additions and 1 deletions

View File

@ -520,6 +520,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
{"transaction_replay", MXS_MODULE_PARAM_BOOL, "false"},
{"transaction_replay_max_size",MXS_MODULE_PARAM_SIZE, "1Mi"},
{"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"},
{"lazy_connect", MXS_MODULE_PARAM_BOOL, "false"},
{MXS_END_MODULE_PARAMS}

View File

@ -161,6 +161,7 @@ struct Config
, transaction_replay(params->get_bool("transaction_replay"))
, trx_max_size(params->get_size("transaction_replay_max_size"))
, 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"))
, lazy_connect(params->get_bool("lazy_connect"))
{
@ -225,6 +226,7 @@ struct Config
bool transaction_replay; /**< Replay failed transactions */
size_t trx_max_size; /**< Max transaction size for replaying */
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 lazy_connect; /**< Create connections only when needed */
};

View File

@ -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.
gwbuf_free(writebuf);