MXS-2419: Queue queries executed during trx replay

By storing the queries in the query queue and routing it once the
transaction replay is done, we prevent two problems:

* Multiple transaction replays would overwrite the m_interrupted_query
  buffer that was used to store any queries executed during the
  transaction replay.

* Incorrect ordering of queries when the query queue is not empty and a
  new query is executed during transaction replay.
This commit is contained in:
Markus Mäkelä 2019-04-02 17:45:22 +03:00
parent 2dfd7d35ac
commit a217dde1f0
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -138,12 +138,11 @@ int32_t RWSplitSession::routeQuery(GWBUF* querybuf)
{
MXS_INFO("New query received while transaction replay is active: %s",
mxs::extract_sql(querybuf).c_str());
mxb_assert(!m_interrupted_query.get());
m_interrupted_query.reset(querybuf);
m_query_queue = gwbuf_append(m_query_queue, querybuf);
return 1;
}
if (m_query_queue == NULL
if ((m_query_queue == NULL || GWBUF_IS_REPLAYED(querybuf))
&& (m_expected_responses == 0
|| m_qc.load_data_state() == QueryClassifier::LOAD_DATA_ACTIVE
|| m_qc.large_query()))
@ -469,6 +468,10 @@ void RWSplitSession::trx_replay_next_stmt()
MXS_INFO("Resuming execution: %s", mxs::extract_sql(m_interrupted_query.get()).c_str());
retry_query(m_interrupted_query.release(), 0);
}
else if (m_query_queue)
{
route_stored_query();
}
}
else
{