MXS-1810: Add transaction checksums

Readwritesplit now calculates checksums for all successful and failed
transactions. This checksum is not of any practical use until the
transaction replaying is implemented.
This commit is contained in:
Markus Mäkelä
2018-04-19 09:25:19 +03:00
parent bb96c368c2
commit 53a5685dc2
2 changed files with 14 additions and 0 deletions

View File

@ -399,6 +399,16 @@ void RWSplitSession::clientReply(GWBUF *writebuf, DCB *backend_dcb)
m_current_query.reset(); m_current_query.reset();
if (session_trx_is_ending(m_client->session))
{
m_trx_checksum.finalize(writebuf);
MXS_INFO("Transaction checksum: %s", m_trx_checksum.hex().c_str());
}
else if (session_trx_is_active(m_client->session))
{
m_trx_checksum.update(writebuf);
}
if (backend->reply_is_complete(writebuf)) if (backend->reply_is_complete(writebuf))
{ {
/** Got a complete reply, acknowledge the write and decrement expected response count */ /** Got a complete reply, acknowledge the write and decrement expected response count */
@ -548,6 +558,8 @@ void RWSplitSession::handleError(GWBUF *errmsgbuf, DCB *problem_dcb,
if (session_trx_is_active(session)) if (session_trx_is_active(session))
{ {
// We have an open transaction, we can't continue // We have an open transaction, we can't continue
m_trx_checksum.finalize();
MXS_INFO("Checksum of failed transaction: %s", m_trx_checksum.hex().c_str());
can_continue = false; can_continue = false;
} }

View File

@ -19,6 +19,7 @@
#include <maxscale/buffer.hh> #include <maxscale/buffer.hh>
#include <maxscale/modutil.h> #include <maxscale/modutil.h>
#include <maxscale/utils.hh>
#include <maxscale/queryclassifier.hh> #include <maxscale/queryclassifier.hh>
#define TARGET_IS_MASTER(t) maxscale::QueryClassifier::target_is_master(t) #define TARGET_IS_MASTER(t) maxscale::QueryClassifier::target_is_master(t)
@ -136,6 +137,7 @@ public:
mxs::QueryClassifier m_qc; /**< The query classifier. */ mxs::QueryClassifier m_qc; /**< The query classifier. */
uint64_t m_retry_duration; /**< Total time spent retrying queries */ uint64_t m_retry_duration; /**< Total time spent retrying queries */
mxs::Buffer m_current_query; /**< Current query being executed */ mxs::Buffer m_current_query; /**< Current query being executed */
mxs::SHA1Checksum m_trx_checksum; /**< Transaction checksum */
private: private:
RWSplitSession(RWSplit* instance, MXS_SESSION* session, RWSplitSession(RWSplit* instance, MXS_SESSION* session,