MXS-2456: Cap transaction replay attempts

In most cases it is reasonable to stop attempting transaction replays
after a certain number of failed attempts. This prevents transactions from
being repeatedly replayed on the same server over and over again if, for
example, it keeps crashing.
This commit is contained in:
Markus Mäkelä
2019-04-30 13:45:48 +03:00
parent bc654849e8
commit 26b2897280
4 changed files with 26 additions and 20 deletions

View File

@ -406,6 +406,7 @@ void RWSplitSession::trx_replay_next_stmt()
// No more statements to execute
m_is_replay_active = false;
mxb::atomic::add(&m_router->stats().n_trx_replay, 1, mxb::atomic::RELAXED);
m_num_trx_replays = 0;
if (!m_replayed_trx.empty())
{
@ -882,7 +883,7 @@ bool RWSplitSession::start_trx_replay()
{
bool rval = false;
if (m_config.transaction_replay && m_can_replay_trx)
if (m_config.transaction_replay && m_can_replay_trx && m_num_trx_replays < m_config.trx_max_attempts)
{
if (!m_is_replay_active)
{
@ -950,6 +951,7 @@ bool RWSplitSession::start_trx_replay()
"transaction had no statements and no query was interrupted");
}
++m_num_trx_replays;
rval = true;
}