MXS-3609: Use 64-bit integers for statistics
This should be enough to avoid the problem of integer overflow in 2.4.
This commit is contained in:
@ -162,7 +162,7 @@ public:
|
|||||||
/* Server connection and usage statistics */
|
/* Server connection and usage statistics */
|
||||||
struct ConnStats
|
struct ConnStats
|
||||||
{
|
{
|
||||||
int n_connections = 0; /**< Number of connections */
|
uint64_t n_connections = 0; /**< Number of connections */
|
||||||
int n_current = 0; /**< Current connections */
|
int n_current = 0; /**< Current connections */
|
||||||
int n_current_ops = 0; /**< Current active operations */
|
int n_current_ops = 0; /**< Current active operations */
|
||||||
int n_persistent = 0; /**< Current persistent pool */
|
int n_persistent = 0; /**< Current persistent pool */
|
||||||
|
|||||||
@ -46,8 +46,8 @@ typedef struct
|
|||||||
{
|
{
|
||||||
time_t started; /**< The time when the service was started */
|
time_t started; /**< The time when the service was started */
|
||||||
int n_failed_starts; /**< Number of times this service has failed to start */
|
int n_failed_starts; /**< Number of times this service has failed to start */
|
||||||
int n_sessions; /**< Number of sessions created on service since start */
|
uint64_t n_sessions; /**< Number of sessions created on service since start */
|
||||||
int n_current; /**< Current number of sessions */
|
uint64_t n_current; /**< Current number of sessions */
|
||||||
} SERVICE_STATS;
|
} SERVICE_STATS;
|
||||||
|
|
||||||
typedef struct server_ref_t
|
typedef struct server_ref_t
|
||||||
|
|||||||
@ -370,7 +370,7 @@ void Server::printServer()
|
|||||||
printf("\tServer: %s\n", address);
|
printf("\tServer: %s\n", address);
|
||||||
printf("\tProtocol: %s\n", m_settings.protocol.c_str());
|
printf("\tProtocol: %s\n", m_settings.protocol.c_str());
|
||||||
printf("\tPort: %d\n", port);
|
printf("\tPort: %d\n", port);
|
||||||
printf("\tTotal connections: %d\n", stats.n_connections);
|
printf("\tTotal connections: %lu\n", stats.n_connections);
|
||||||
printf("\tCurrent connections: %d\n", stats.n_current);
|
printf("\tCurrent connections: %d\n", stats.n_current);
|
||||||
printf("\tPersistent connections: %d\n", stats.n_persistent);
|
printf("\tPersistent connections: %d\n", stats.n_persistent);
|
||||||
printf("\tPersistent actual max: %d\n", persistmax);
|
printf("\tPersistent actual max: %d\n", persistmax);
|
||||||
@ -496,7 +496,7 @@ void Server::print_to_dcb(DCB* dcb) const
|
|||||||
elem.first.c_str(), elem.second.c_str());
|
elem.first.c_str(), elem.second.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dcb_printf(dcb, "\tNumber of connections: %d\n", server->stats.n_connections);
|
dcb_printf(dcb, "\tNumber of connections: %lu\n", server->stats.n_connections);
|
||||||
dcb_printf(dcb, "\tCurrent no. of conns: %d\n", server->stats.n_current);
|
dcb_printf(dcb, "\tCurrent no. of conns: %d\n", server->stats.n_current);
|
||||||
dcb_printf(dcb, "\tCurrent no. of operations: %d\n", server->stats.n_current_ops);
|
dcb_printf(dcb, "\tCurrent no. of operations: %d\n", server->stats.n_current_ops);
|
||||||
dcb_printf(dcb, "\tNumber of routed packets: %lu\n", server->stats.packets);
|
dcb_printf(dcb, "\tNumber of routed packets: %lu\n", server->stats.packets);
|
||||||
|
|||||||
@ -961,10 +961,10 @@ void dprintService(DCB* dcb, SERVICE* svc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"\tTotal connections: %d\n",
|
"\tTotal connections: %lu\n",
|
||||||
service->stats.n_sessions);
|
service->stats.n_sessions);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"\tCurrently connected: %d\n",
|
"\tCurrently connected: %lu\n",
|
||||||
service->stats.n_current);
|
service->stats.n_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -993,7 +993,7 @@ void dListServices(DCB* dcb)
|
|||||||
{
|
{
|
||||||
mxb_assert(service->stats.n_current >= 0);
|
mxb_assert(service->stats.n_current >= 0);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"%-25s | %-17s | %6d | %14d | ",
|
"%-25s | %-17s | %6lu | %14lu | ",
|
||||||
service->name(),
|
service->name(),
|
||||||
service->router_name(),
|
service->router_name(),
|
||||||
service->stats.n_current,
|
service->stats.n_current,
|
||||||
|
|||||||
@ -496,13 +496,13 @@ void RCR::diagnostics(DCB* dcb)
|
|||||||
const char* weightby = serviceGetWeightingParameter(m_pService);
|
const char* weightby = serviceGetWeightingParameter(m_pService);
|
||||||
|
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"\tNumber of router sessions: %d\n",
|
"\tNumber of router sessions: %lu\n",
|
||||||
m_stats.n_sessions);
|
m_stats.n_sessions);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"\tCurrent no. of router sessions: %d\n",
|
"\tCurrent no. of router sessions: %lu\n",
|
||||||
m_pService->stats.n_current);
|
m_pService->stats.n_current);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"\tNumber of queries forwarded: %d\n",
|
"\tNumber of queries forwarded: %lu\n",
|
||||||
m_stats.n_queries);
|
m_stats.n_queries);
|
||||||
if (*weightby)
|
if (*weightby)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -84,8 +84,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
struct Stats
|
struct Stats
|
||||||
{
|
{
|
||||||
int n_sessions = 0; /**< Number sessions created */
|
uint64_t n_sessions = 0; /**< Number sessions created */
|
||||||
int n_queries = 0; /**< Number of queries forwarded */
|
uint64_t n_queries = 0; /**< Number of queries forwarded */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -317,7 +317,7 @@ void RWSplit::diagnostics(DCB* dcb)
|
|||||||
"\tNumber of router sessions: %" PRIu64 "\n",
|
"\tNumber of router sessions: %" PRIu64 "\n",
|
||||||
stats().n_sessions);
|
stats().n_sessions);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"\tCurrent no. of router sessions: %d\n",
|
"\tCurrent no. of router sessions: %lu\n",
|
||||||
service()->stats.n_current);
|
service()->stats.n_current);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"\tNumber of queries forwarded: %" PRIu64 "\n",
|
"\tNumber of queries forwarded: %" PRIu64 "\n",
|
||||||
|
|||||||
@ -70,14 +70,14 @@ typedef std::shared_ptr<Config> SConfig;
|
|||||||
*/
|
*/
|
||||||
struct Stats
|
struct Stats
|
||||||
{
|
{
|
||||||
int n_queries; /*< Number of queries forwarded */
|
uint64_t n_queries; /*< Number of queries forwarded */
|
||||||
int n_sescmd; /*< Number of session commands */
|
uint64_t n_sescmd; /*< Number of session commands */
|
||||||
int longest_sescmd; /*< Longest chain of stored session commands */
|
uint64_t longest_sescmd; /*< Longest chain of stored session commands */
|
||||||
int n_hist_exceeded; /*< Number of sessions that exceeded session
|
uint64_t n_hist_exceeded; /*< Number of sessions that exceeded session
|
||||||
* command history limit */
|
* command history limit */
|
||||||
int sessions; /*< Number of sessions */
|
uint64_t sessions; /*< Number of sessions */
|
||||||
int shmap_cache_hit; /*< Shard map was found from the cache */
|
uint64_t shmap_cache_hit; /*< Shard map was found from the cache */
|
||||||
int shmap_cache_miss;/*< No shard map found from the cache */
|
uint64_t shmap_cache_miss; /*< No shard map found from the cache */
|
||||||
double ses_longest; /*< Longest session */
|
double ses_longest; /*< Longest session */
|
||||||
double ses_shortest; /*< Shortest session */
|
double ses_shortest; /*< Shortest session */
|
||||||
double ses_average; /*< Average session length */
|
double ses_average; /*< Average session length */
|
||||||
|
|||||||
@ -212,16 +212,16 @@ void SchemaRouter::diagnostics(DCB* dcb)
|
|||||||
/** Session command statistics */
|
/** Session command statistics */
|
||||||
dcb_printf(dcb, "\n\33[1;4mSession Commands\33[0m\n");
|
dcb_printf(dcb, "\n\33[1;4mSession Commands\33[0m\n");
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"Total number of queries: %d\n",
|
"Total number of queries: %lu\n",
|
||||||
m_stats.n_queries);
|
m_stats.n_queries);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"Percentage of session commands: %.2f\n",
|
"Percentage of session commands: %.2f\n",
|
||||||
sescmd_pct);
|
sescmd_pct);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"Longest chain of stored session commands: %d\n",
|
"Longest chain of stored session commands: %lu\n",
|
||||||
m_stats.longest_sescmd);
|
m_stats.longest_sescmd);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"Session command history limit exceeded: %d times\n",
|
"Session command history limit exceeded: %lu times\n",
|
||||||
m_stats.n_hist_exceeded);
|
m_stats.n_hist_exceeded);
|
||||||
|
|
||||||
/** Session time statistics */
|
/** Session time statistics */
|
||||||
@ -233,8 +233,8 @@ void SchemaRouter::diagnostics(DCB* dcb)
|
|||||||
dcb_printf(dcb, "Shortest session: %.2lf seconds\n", m_stats.ses_shortest);
|
dcb_printf(dcb, "Shortest session: %.2lf seconds\n", m_stats.ses_shortest);
|
||||||
dcb_printf(dcb, "Average session length: %.2lf seconds\n", m_stats.ses_average);
|
dcb_printf(dcb, "Average session length: %.2lf seconds\n", m_stats.ses_average);
|
||||||
}
|
}
|
||||||
dcb_printf(dcb, "Shard map cache hits: %d\n", m_stats.shmap_cache_hit);
|
dcb_printf(dcb, "Shard map cache hits: %lu\n", m_stats.shmap_cache_hit);
|
||||||
dcb_printf(dcb, "Shard map cache misses: %d\n", m_stats.shmap_cache_miss);
|
dcb_printf(dcb, "Shard map cache misses: %lu\n", m_stats.shmap_cache_miss);
|
||||||
dcb_printf(dcb, "\n");
|
dcb_printf(dcb, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user