MXS-2187: Allow multiple transaction retries

By resetting the replay state the transaction replay can start again on a
new server. This allows the replay process work when a master server is
shutting down.
This commit is contained in:
Markus Mäkelä
2018-11-26 13:37:10 +02:00
parent e6325d39fb
commit 1abcbd64bd
2 changed files with 20 additions and 3 deletions

View File

@ -775,8 +775,23 @@ bool RWSplitSession::start_trx_replay()
{
bool rval = false;
if (!m_is_replay_active && m_config.transaction_replay && m_can_replay_trx)
if (m_config.transaction_replay && m_can_replay_trx)
{
if (!m_is_replay_active)
{
// This is the first time we're retrying this transaction, store it and the interrupted query
m_orig_trx = m_trx;
m_orig_stmt.copy_from(m_current_query);
}
else
{
// Not the first time, copy the original
m_replayed_trx.close();
m_trx.close();
m_trx = m_orig_trx;
m_current_query.copy_from(m_orig_stmt);
}
if (m_trx.have_stmts() || m_current_query.get())
{
// Stash any interrupted queries while we replay the transaction

View File

@ -163,8 +163,10 @@ public:
* transaction */
bool m_can_replay_trx; /**< Whether the transaction can be replayed */
Trx m_replayed_trx; /**< The transaction we are replaying */
mxs::Buffer m_interrupted_query; /**< Query that was interrupted mid-transaction.
* */
mxs::Buffer m_interrupted_query; /**< Query that was interrupted mid-transaction. */
Trx m_orig_trx; /**< The backup of the transaction we're replaying */
mxs::Buffer m_orig_stmt; /**< The backup of the statement that was interrupted */
otrx_state m_otrx_state = OTRX_INACTIVE; /**< Optimistic trx state*/
private: