MXS-1507: Fix replaying of empty transactions

If the starting of a transaction was interrupted by a server failure, the
query needs to be retried. This needs to be done as a transaction replay
to keep the routing logic consistent and simple.

When a non-autocommit transaction is interrupted, there will be no query
in progress and no replaying is needed. To handle this case, the replay
initialization logic needed to be altered to treat truly empty
transactions as a success case.
This commit is contained in:
Markus Mäkelä
2018-06-03 19:16:03 +03:00
parent 74cc74ed66
commit 445eece95b
3 changed files with 119 additions and 47 deletions

View File

@ -83,13 +83,27 @@ public:
}
/**
* Check if transaction is empty
* Check if transaction has statements
*
* @return True if transaction has no statements
* @return True if transaction has statements
*
* @note This function should only be used when checking whether a transaction
* that is being replayed has ended. The empty() method can be used
* to check whether statements were added to the transaction.
*/
bool have_stmts() const
{
return !m_log.empty();
}
/**
* Check whether the transaction is empty
*
* @return True if no statements have been added to the transaction
*/
bool empty() const
{
return m_log.empty();
return m_size == 0;
}
/**