MXS-1507: Retry interrupted queries in transactions
As the current query was added to the transaction log before it finished, the m_current_query contained a duplicate of the latest transaction log entry. To correctly log only successful transactions, the statement should be added only after it has successfully completed. This change also removed the unnecessary cloning that took place when the statement was added to the log before it finished. With the fixed transaction logging, the value of m_current_query can be stashed for later retrying while the replay process is happening. If the replay completes successfully and the checksums match, the interrupted query is retried. Also added a clarifying comment to can_retry_query to explain why a query inside a transaction cannot be retried.
This commit is contained in:
@ -140,6 +140,7 @@ public:
|
||||
Trx m_trx; /**< Current transaction */
|
||||
bool m_is_replay_active; /**< Whether we are actively replaying a transaction */
|
||||
Trx m_replayed_trx; /**< The transaction we are replaying */
|
||||
mxs::Buffer m_interrupted_query; /**< Query that was interrupted mid-transaction. */
|
||||
|
||||
private:
|
||||
RWSplitSession(RWSplit* instance, MXS_SESSION* session,
|
||||
@ -194,6 +195,12 @@ private:
|
||||
|
||||
inline bool can_retry_query() const
|
||||
{
|
||||
/** Individual queries can only be retried if we are not inside
|
||||
* a transaction. If a query in a transaction needs to be retried,
|
||||
* the whole transaction must be replayed before the retrying is done.
|
||||
*
|
||||
* @see handle_trx_replay
|
||||
*/
|
||||
return m_config.delayed_retry &&
|
||||
m_retry_duration < m_config.delayed_retry_timeout &&
|
||||
!session_trx_is_active(m_client->session);
|
||||
|
||||
Reference in New Issue
Block a user