MXS-1507: Add transaction replay statistics

Added a simple counter for the number of replayed transactions.
This commit is contained in:
Markus Mäkelä
2018-05-02 09:09:32 +03:00
parent 8a52478afa
commit ff8a7c8b93
3 changed files with 13 additions and 7 deletions

View File

@ -358,18 +358,20 @@ void RWSplit::diagnostics(DCB *dcb)
all_pct = ((double)stats().n_all / (double)stats().n_queries) * 100.0; all_pct = ((double)stats().n_all / (double)stats().n_queries) * 100.0;
} }
dcb_printf(dcb, "\tNumber of router sessions: %" PRIu64 "\n", dcb_printf(dcb, "\tNumber of router sessions: %" PRIu64 "\n",
stats().n_sessions); stats().n_sessions);
dcb_printf(dcb, "\tCurrent no. of router sessions: %d\n", dcb_printf(dcb, "\tCurrent no. of router sessions: %d\n",
service()->stats.n_current); service()->stats.n_current);
dcb_printf(dcb, "\tNumber of queries forwarded: %" PRIu64 "\n", dcb_printf(dcb, "\tNumber of queries forwarded: %" PRIu64 "\n",
stats().n_queries); stats().n_queries);
dcb_printf(dcb, "\tNumber of queries forwarded to master: %" PRIu64 " (%.2f%%)\n", dcb_printf(dcb, "\tNumber of queries forwarded to master: %" PRIu64 " (%.2f%%)\n",
stats().n_master, master_pct); stats().n_master, master_pct);
dcb_printf(dcb, "\tNumber of queries forwarded to slave: %" PRIu64 " (%.2f%%)\n", dcb_printf(dcb, "\tNumber of queries forwarded to slave: %" PRIu64 " (%.2f%%)\n",
stats().n_slave, slave_pct); stats().n_slave, slave_pct);
dcb_printf(dcb, "\tNumber of queries forwarded to all: %" PRIu64 " (%.2f%%)\n", dcb_printf(dcb, "\tNumber of queries forwarded to all: %" PRIu64 " (%.2f%%)\n",
stats().n_all, all_pct); stats().n_all, all_pct);
dcb_printf(dcb, "\tNumber of replayed transactions: %" PRIu64 "\n",
stats().n_trx_replay);
if (*weightby) if (*weightby)
{ {
@ -399,6 +401,7 @@ json_t* RWSplit::diagnostics_json() const
json_object_set_new(rval, "route_master", json_integer(stats().n_master)); json_object_set_new(rval, "route_master", json_integer(stats().n_master));
json_object_set_new(rval, "route_slave", json_integer(stats().n_slave)); json_object_set_new(rval, "route_slave", json_integer(stats().n_slave));
json_object_set_new(rval, "route_all", json_integer(stats().n_all)); json_object_set_new(rval, "route_all", json_integer(stats().n_all));
json_object_set_new(rval, "replayed_transactions", json_integer(stats().n_trx_replay));
const char *weightby = serviceGetWeightingParameter(service()); const char *weightby = serviceGetWeightingParameter(service());

View File

@ -211,7 +211,8 @@ public:
n_queries(0), n_queries(0),
n_master(0), n_master(0),
n_slave(0), n_slave(0),
n_all(0) n_all(0),
n_trx_replay(0)
{ {
} }
@ -220,6 +221,7 @@ public:
uint64_t n_master; /**< Number of stmts sent to master */ uint64_t n_master; /**< Number of stmts sent to master */
uint64_t n_slave; /**< Number of stmts sent to slave */ uint64_t n_slave; /**< Number of stmts sent to slave */
uint64_t n_all; /**< Number of stmts sent to all */ uint64_t n_all; /**< Number of stmts sent to all */
uint64_t n_trx_replay; /**< Number of replayed transactions */
}; };
class RWSplitSession; class RWSplitSession;

View File

@ -380,6 +380,7 @@ void RWSplitSession::handle_trx_replay()
{ {
// No more statements to execute // No more statements to execute
m_is_replay_active = false; m_is_replay_active = false;
atomic_add_uint64(&m_router->stats().n_trx_replay, 1);
// Check that the checksums match. // Check that the checksums match.
SHA1Checksum chksum = m_trx.checksum(); SHA1Checksum chksum = m_trx.checksum();