Added new prometheus metrics mimicking current ones

pull/2676/head
Javier Jaramago Fernández 6 years ago
parent e703178f04
commit c319db2c3d

@ -10,6 +10,9 @@
#include "thread.h"
#include "wqueue.h"
// Headers for declaring Prometheus counters
#include <prometheus/counter.h>
#include <prometheus/gauge.h>
#include "ev.h"
@ -352,6 +355,49 @@ class MySQL_HostGroups_Manager {
unsigned long long access_denied_max_connections;
unsigned long long access_denied_max_user_connections;
unsigned long long select_for_update_or_equivalent;
//////////////////////////////////////////////////////
/// Prometheus Metrics ///
//////////////////////////////////////////////////////
/// Prometheus client metrics
prometheus::Counter* p_client_connections_created { nullptr };
prometheus::Counter* p_client_connections_aborted { nullptr };
prometheus::Gauge* p_client_connections { nullptr };
/// Prometheus server metrics
prometheus::Counter* p_server_connections_aborted { nullptr };
prometheus::Counter* p_server_connections_created { nullptr };
prometheus::Counter* p_server_connections_delayed { nullptr };
prometheus::Gauge* p_server_connections_connected { nullptr };
/// Prometheus access metrics
prometheus::Counter* p_access_denied_wrong_password { nullptr };
prometheus::Counter* p_access_denied_max_connections { nullptr };
prometheus::Counter* p_access_denied_max_user_connections { nullptr };
/// TODO: Prometheus myconnpoll metrics
prometheus::Counter* p_myconnpoll_get { nullptr };
prometheus::Counter* p_myconnpoll_get_ok { nullptr };
prometheus::Counter* p_myconnpoll_get_ping { nullptr };
prometheus::Counter* p_myconnpoll_push { nullptr };
prometheus::Counter* p_myconnpoll_reset { nullptr };
prometheus::Counter* p_myconnpoll_destroy { nullptr };
/// Prometheus backend metrics
prometheus::Counter* p_backend_change_user { nullptr };
prometheus::Counter* p_backend_init_db { nullptr };
prometheus::Counter* p_backend_set_names { nullptr };
/// Prometheus frontend metrics
prometheus::Counter* p_frontend_init_db { nullptr };
prometheus::Counter* p_frontend_set_names { nullptr };
prometheus::Counter* p_frontend_use_db { nullptr };
/// Prometheus ** metrics
prometheus::Counter* p_autocommit_cnt { nullptr };
prometheus::Counter* p_commit_cnt { nullptr };
prometheus::Counter* p_rollback_cnt { nullptr };
prometheus::Counter* p_autocommit_cnt_filtered { nullptr };
prometheus::Counter* p_commit_cnt_filtered { nullptr };
prometheus::Counter* p_rollback_cnt_filtered { nullptr };
prometheus::Counter* p_select_for_update_or_equivalent { nullptr };
//////////////////////////////////////////////////////
} status;
wqueue<MySQL_Connection *> queue;
MySQL_HostGroups_Manager();

@ -1,10 +1,15 @@
#ifndef __CLASS_MYSQL_MONITOR_H
#define __CLASS_MYSQL_MONITOR_H
#include "prometheus/gauge.h"
#include "proxysql.h"
#include "cpp.h"
#include "thread.h"
#include "wqueue.h"
// Headers for declaring Prometheus counters
#include <prometheus/counter.h>
#include <prometheus/gauge.h>
//#define MONITOR_SQLITE_TABLE_MYSQL_SERVER_CONNECT "CREATE TABLE mysql_server_connect (hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 3306 , time_since INT NOT NULL DEFAULT 0 , time_until INT NOT NULL DEFAULT 0 , connect_success_count INT NOT NULL DEFAULT 0 , connect_success_first INT NOT NULL DEFAULT 0 , connect_success_last INT NOT NULL DEFAULT 0 , connect_success_time_min INT NOT NULL DEFAULT 0 , connect_success_time_max INT NOT NULL DEFAULT 0 , connect_success_time_total INT NOT NULL DEFAULT 0 , connect_failure_count INT NOT NULL DEFAULT 0 , connect_failure_first INT NOT NULL DEFAULT 0 , connect_failure_last INT NOT NULL DEFAULT 0 , PRIMARY KEY (hostname, port))"
//#define MONITOR_SQLITE_TABLE_MYSQL_SERVER_PING "CREATE TABLE mysql_server_ping (hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 3306 , time_since INT NOT NULL DEFAULT 0 , time_until INT NOT NULL DEFAULT 0 , ping_success_count INT NOT NULL DEFAULT 0 , ping_success_first INT NOT NULL DEFAULT 0, ping_success_last INT NOT NULL DEFAULT 0 , ping_success_time_min INT NOT NULL DEFAULT 0 , ping_success_time_max INT NOT NULL DEFAULT 0 , ping_success_time_total INT NOT NULL DEFAULT 0 , ping_failure_count INT NOT NULL DEFAULT 0 , ping_failure_first INT NOT NULL DEFAULT 0 , ping_failure_last INT NOT NULL DEFAULT 0 , PRIMARY KEY (hostname, port))"
@ -254,6 +259,19 @@ class MySQL_Monitor {
unsigned long long read_only_check_ERR;
unsigned long long replication_lag_check_OK;
unsigned long long replication_lag_check_ERR;
struct {
prometheus::Gauge* p_num_threads { nullptr };
prometheus::Gauge* p_aux_threads { nullptr };
prometheus::Counter* p_started_threads { nullptr };
prometheus::Counter* p_connect_check_OK { nullptr };
prometheus::Counter* p_connect_check_ERR { nullptr };
prometheus::Counter* p_ping_check_OK { nullptr };
prometheus::Counter* p_ping_check_ERR { nullptr };
prometheus::Counter* p_read_only_check_OK { nullptr };
prometheus::Counter* p_read_only_check_ERR { nullptr };
prometheus::Counter* p_replication_lag_check_OK { nullptr };
prometheus::Counter* p_replication_lag_check_ERR { nullptr };
} metrics;
std::unique_ptr<wqueue<WorkItem*>> queue;
MySQL_Monitor_Connection_Pool *My_Conn_Pool;
bool shutdown;

@ -9,6 +9,10 @@
#endif // IDLE_THREADS
#include <atomic>
// Headers for declaring Prometheus counters
#include <prometheus/counter.h>
#include <prometheus/gauge.h>
#define MIN_POLL_LEN 8
#define MIN_POLL_DELETE_RATIO 8
#define MY_EPOLL_THREAD_MAXEVENTS 128
@ -394,6 +398,59 @@ class MySQL_Threads_Handler
} variables;
struct {
unsigned int mirror_sessions_current;
//////////////////////////////////////////////////////
/// Prometheus Metrics ///
//////////////////////////////////////////////////////
prometheus::Gauge* p_active_transations { nullptr };
prometheus::Gauge* p_non_idle_client_connections { nullptr };
prometheus::Counter* p_queries_backends_bytes_recv { nullptr };
prometheus::Counter* p_queries_backends_bytes_sent { nullptr };
prometheus::Counter* p_queries_frontends_bytes_recv { nullptr };
prometheus::Counter* p_queries_frontends_bytes_sent { nullptr };
prometheus::Counter* p_query_processor_time { nullptr };
prometheus::Counter* p_backend_query_time { nullptr };
prometheus::Gauge* p_mysql_backend_buffers_bytes { nullptr };
prometheus::Gauge* p_mysql_frontend_buffers_bytes { nullptr };
prometheus::Gauge* p_mysql_session_internal_bytes { nullptr };
prometheus::Counter* p_total_backend_stmt_prepare { nullptr };
prometheus::Counter* p_total_backend_stmt_execute { nullptr };
prometheus::Counter* p_total_backend_stmt_close { nullptr };
prometheus::Counter* p_total_frontend_stmt_prepare { nullptr };
prometheus::Counter* p_total_frontend_stmt_execute { nullptr };
prometheus::Counter* p_total_frontend_stmt_close { nullptr };
prometheus::Gauge* p_mirror_sessions_current { nullptr };
prometheus::Gauge* p_total_mirror_queue { nullptr };
prometheus::Counter* p_total_queries { nullptr };
prometheus::Counter* p_slow_queries { nullptr };
prometheus::Counter* p_gtid_queries { nullptr };
prometheus::Counter* p_gtid_session_collected { nullptr };
prometheus::Counter* p_servers_table_version { nullptr };
prometheus::Gauge* p_num_threads { nullptr };
prometheus::Counter* p_ConnPool_get_conn_latency_awareness { nullptr };
prometheus::Counter* p_ConnPool_get_conn_immediate { nullptr };
prometheus::Counter* p_ConnPool_get_conn_success { nullptr };
prometheus::Counter* p_ConnPool_get_conn_failure { nullptr };
prometheus::Counter* p_generated_error_packets { nullptr };
prometheus::Counter* p_max_connect_timeout { nullptr };
prometheus::Counter* p_backend_lagging_during_query { nullptr };
prometheus::Counter* p_backend_offline_during_query { nullptr };
prometheus::Counter* p_queries_with_max_lag_ms { nullptr };
prometheus::Counter* p_queries_with_max_lag_ms__delayed { nullptr };
prometheus::Counter* p_queries_with_max_lag_ms__total_wait_time_us { nullptr };
prometheus::Counter* p_mysql_unexpected_frontend_com_quit { nullptr };
prometheus::Counter* p_get_hostgroup_locked { nullptr };
prometheus::Counter* p_hostgroup_locked_set_cmds { nullptr };
prometheus::Counter* p_hostgroup_locked_queries { nullptr };
prometheus::Counter* p_mysql_unexpected_frontend_packets { nullptr };
prometheus::Counter* p_aws_aurora_replicas_skipped_during_query { nullptr };
prometheus::Counter* p_automatic_detected_sqli { nullptr };
prometheus::Counter* p_whitelisted_sqli_fingerprint { nullptr };
prometheus::Counter* p_killed_connections { nullptr };
prometheus::Counter* p_killed_queries { nullptr };
//////////////////////////////////////////////////////
} status_variables;
unsigned int num_threads;
proxysql_mysql_thread_t *mysql_threads;

@ -1,9 +1,12 @@
#include "prometheus/counter.h"
#include "prometheus/gauge.h"
#include "proxysql.h"
#include "cpp.h"
#include "SpookyV2.h"
#include "MySQL_PreparedStatement.h"
#include "MySQL_Data_Stream.h"
#include <memory>
#define char_malloc (char *)malloc
#define itostr(__s, __i) { __s=char_malloc(32); sprintf(__s, "%lld", __i); }
@ -855,6 +858,7 @@ void MySrvC::connect_error(int err_num) {
// as a single connection failure won't make a significant difference
__sync_fetch_and_add(&connect_ERR,1);
__sync_fetch_and_add(&MyHGM->status.server_connections_aborted,1);
MyHGM->status.p_server_connections_aborted->Increment();
if (err_num >= 1048 && err_num <= 1052)
return;
if (err_num >= 1054 && err_num <= 1075)
@ -1020,6 +1024,68 @@ MySQL_HostGroups_Manager::MySQL_HostGroups_Manager() {
rand_del[7] = 0;
}
pthread_mutex_init(&mysql_errors_mutex, NULL);
// Create and register prometheus metrics
auto& new_gauge_family {
prometheus::BuildGauge()
.Name("MySQL_HostGroups_Manager_Gauges")
.Register(*GloVars.prometheus_registry)
};
auto& new_counter_family {
prometheus::BuildCounter()
.Name("MySQL_HostGroups_Manager_Counters")
.Register(*GloVars.prometheus_registry)
};
// Server_Connections counters
this->status.p_server_connections_connected =
std::addressof(new_gauge_family.Add({{ "id", "Server_Connections_connected" }}));
this->status.p_server_connections_created =
std::addressof(new_counter_family.Add({{ "id", "Server_Connections_created" }}));
this->status.p_server_connections_delayed =
std::addressof(new_counter_family.Add({{ "id", "Server_Connections_delayed" }}));
this->status.p_server_connections_aborted =
std::addressof(new_counter_family.Add({{ "id", "Server_Connections_aborted" }}));
// Client_Connections counters
this->status.p_client_connections_created =
std::addressof(new_counter_family.Add({{ "id", "Client_Connections_created" }}));
this->status.p_client_connections_aborted =
std::addressof(new_counter_family.Add({{ "id", "Client_Connections_aborted" }}));
this->status.p_client_connections =
std::addressof(new_gauge_family.Add({{ "id", "Client_Connections_connected" }}));
// Com_* counters
this->status.p_autocommit_cnt =
std::addressof(new_counter_family.Add({{ "id", "Com_autocommit" }}));
this->status.p_autocommit_cnt_filtered =
std::addressof(new_counter_family.Add({{ "id", "Com_autocommit_filtered" }}));
this->status.p_rollback_cnt =
std::addressof(new_counter_family.Add({{ "id", "Com_rollback" }}));
this->status.p_rollback_cnt_filtered =
std::addressof(new_counter_family.Add({{ "id", "Com_rollback_filtered" }}));
this->status.p_backend_change_user =
std::addressof(new_counter_family.Add({{ "id", "Com_backend_change_user" }}));
this->status.p_backend_init_db =
std::addressof(new_counter_family.Add({{ "id", "Com_backend_init_db" }}));
this->status.p_backend_set_names =
std::addressof(new_counter_family.Add({{ "id", "Com_backend_set_names" }}));
this->status.p_frontend_init_db =
std::addressof(new_counter_family.Add({{ "id", "Com_frontend_init_db" }}));
this->status.p_frontend_set_names =
std::addressof(new_counter_family.Add({{ "id", "Com_frontend_set_names" }}));
this->status.p_frontend_use_db =
std::addressof(new_counter_family.Add({{ "id", "Com_frontend_use_db" }}));
this->status.p_select_for_update_or_equivalent =
std::addressof(new_counter_family.Add({{ "id", "Selects_for_update__autocommit0" }}));
// Access_* errors
this->status.p_access_denied_wrong_password =
std::addressof(new_counter_family.Add({{ "id", "Access_Denied_Wrong_Password" }}));
this->status.p_access_denied_max_connections =
std::addressof(new_counter_family.Add({{ "id", "Access_Denied_Max_Connections" }}));
this->status.p_access_denied_max_user_connections =
std::addressof(new_counter_family.Add({{ "id", "Access_Denied_Max_User_Connections" }}));
}
void MySQL_HostGroups_Manager::init() {
@ -2743,6 +2809,7 @@ MySQL_Connection * MySrvConnList::get_random_MyConn(MySQL_Session *sess, bool ff
conn = new MySQL_Connection();
conn->parent=mysrvc;
__sync_fetch_and_add(&MyHGM->status.server_connections_created, 1);
MyHGM->status.p_server_connections_created->Increment();
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Returning MySQL Connection %p, server %s:%d\n", conn, conn->parent->address, conn->parent->port);
} else {
// we may consider creating a new connection
@ -2752,6 +2819,7 @@ MySQL_Connection * MySrvConnList::get_random_MyConn(MySQL_Session *sess, bool ff
conn = new MySQL_Connection();
conn->parent=mysrvc;
__sync_fetch_and_add(&MyHGM->status.server_connections_created, 1);
MyHGM->status.p_server_connections_created->Increment();
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Returning MySQL Connection %p, server %s:%d\n", conn, conn->parent->address, conn->parent->port);
} else {
conn=(MySQL_Connection *)conns->remove_index_fast(i);
@ -2774,11 +2842,13 @@ MySQL_Connection * MySrvConnList::get_random_MyConn(MySQL_Session *sess, bool ff
_myhgc->new_connections_now++;
if (_myhgc->new_connections_now > (unsigned int) mysql_thread___throttle_connections_per_sec_to_hostgroup) {
__sync_fetch_and_add(&MyHGM->status.server_connections_delayed, 1);
MyHGM->status.p_server_connections_delayed->Increment();
return NULL;
} else {
conn = new MySQL_Connection();
conn->parent=mysrvc;
__sync_fetch_and_add(&MyHGM->status.server_connections_created, 1);
MyHGM->status.p_server_connections_created->Increment();
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Returning MySQL Connection %p, server %s:%d\n", conn, conn->parent->address, conn->parent->port);
return conn;
}

@ -608,6 +608,38 @@ MySQL_Monitor::MySQL_Monitor() {
num_threads=16; // limit to 16
}
*/
// Create and register prometheus metrics families
auto& new_gauge_family {
prometheus::BuildGauge()
.Name("MySQL_Monitor_Gauges")
.Register(*GloVars.prometheus_registry)
};
auto& new_counter_family {
prometheus::BuildCounter()
.Name("MySQL_Monitor_Counters")
.Register(*GloVars.prometheus_registry)
};
// Initialize prometheus metrics
this->metrics.p_num_threads =
std::addressof(new_gauge_family.Add({{ "id", "MySQL_Monitor_Workers" }}));
this->metrics.p_aux_threads =
std::addressof(new_gauge_family.Add({{ "id", "MySQL_Monitor_Workers_Aux" }}));
this->metrics.p_started_threads =
std::addressof(new_counter_family.Add({{ "id", "MySQL_Monitor_Workers_Started" }}));
this->metrics.p_connect_check_OK =
std::addressof(new_counter_family.Add({{ "id", "MySQL_Monitor_connect_check_OK" }}));
this->metrics.p_connect_check_ERR =
std::addressof(new_counter_family.Add({{ "id", "MySQL_Monitor_connect_check_ERR" }}));
this->metrics.p_ping_check_OK =
std::addressof(new_counter_family.Add({{ "id", "MySQL_Monitor_ping_check_OK" }}));
this->metrics.p_ping_check_ERR =
std::addressof(new_counter_family.Add({{ "id", "MySQL_Monitor_ping_check_ERR" }}));
this->metrics.p_replication_lag_check_OK =
std::addressof(new_counter_family.Add({{ "id", "MySQL_Monitor_read_only_check_OK" }}));
this->metrics.p_replication_lag_check_ERR =
std::addressof(new_counter_family.Add({{ "id", "MySQL_Monitor_read_only_check_ERR" }}));
};
MySQL_Monitor::~MySQL_Monitor() {
@ -3055,6 +3087,7 @@ __monitor_run:
threads[i]->start(2048,false);
}
started_threads += num_threads;
this->metrics.p_started_threads->Increment(num_threads);
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize (&attr, 2048*1024);
@ -3104,6 +3137,7 @@ __monitor_run:
unsigned int threads_min = (unsigned int)mysql_thread___monitor_threads_min;
if (old_num_threads < threads_min) {
num_threads = threads_min;
this->metrics.p_num_threads->Set(static_cast<double>(threads_min));
threads= (ConsumerThread **)realloc(threads, sizeof(ConsumerThread *)*num_threads);
started_threads += (num_threads - old_num_threads);
for (unsigned int i = old_num_threads ; i < num_threads ; i++) {
@ -3132,6 +3166,7 @@ __monitor_run:
if (new_threads) {
unsigned int old_num_threads = num_threads;
num_threads += new_threads;
this->metrics.p_num_threads->Increment(num_threads);
threads= (ConsumerThread **)realloc(threads, sizeof(ConsumerThread *)*num_threads);
started_threads += new_threads;
for (unsigned int i = old_num_threads ; i < num_threads ; i++) {

@ -170,12 +170,14 @@ MySQL_STMT_Global_info::MySQL_STMT_Global_info(uint64_t id, unsigned int h,
p += ql - 11;
if (strncasecmp(p, " FOR UPDATE", 11) == 0) { // is a SELECT FOR UPDATE
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
goto __exit_MySQL_STMT_Global_info___search_select;
}
p = q;
p += ql-10;
if (strncasecmp(p, " FOR SHARE", 10) == 0) { // is a SELECT FOR SHARE
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
goto __exit_MySQL_STMT_Global_info___search_select;
}
if (ql >= 25) {
@ -183,6 +185,7 @@ MySQL_STMT_Global_info::MySQL_STMT_Global_info(uint64_t id, unsigned int h,
p += ql-19;
if (strncasecmp(p, " LOCK IN SHARE MODE", 19) == 0) { // is a SELECT LOCK IN SHARE MODE
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
goto __exit_MySQL_STMT_Global_info___search_select;
}
p = q;
@ -190,6 +193,7 @@ MySQL_STMT_Global_info::MySQL_STMT_Global_info(uint64_t id, unsigned int h,
if (strncasecmp(p," NOWAIT",7)==0) {
// let simplify. If NOWAIT is used, we assume FOR UPDATE|SHARE is used
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
goto __exit_MySQL_STMT_Global_info___search_select;
/*
if (strcasestr(q," FOR UPDATE ")) {
@ -207,6 +211,7 @@ MySQL_STMT_Global_info::MySQL_STMT_Global_info(uint64_t id, unsigned int h,
if (strncasecmp(p," SKIP LOCKED",12)==0) {
// let simplify. If SKIP LOCKED is used, we assume FOR UPDATE|SHARE is used
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
goto __exit_MySQL_STMT_Global_info___search_select;
/*
if (strcasestr(q," FOR UPDATE ")==NULL) {
@ -232,10 +237,12 @@ MySQL_STMT_Global_info::MySQL_STMT_Global_info(uint64_t id, unsigned int h,
if (strcasestr(buf," FOR ")) {
if (strcasestr(buf," FOR UPDATE ")) {
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
goto __exit_MySQL_STMT_Global_info___search_select;
}
if (strcasestr(buf," FOR SHARE ")) {
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
goto __exit_MySQL_STMT_Global_info___search_select;
}
}

@ -327,12 +327,14 @@ bool Query_Info::is_select_NOT_for_update() {
p+=ql-11;
if (strncasecmp(p," FOR UPDATE",11)==0) {
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
return false;
}
p=QP;
p+=ql-10;
if (strncasecmp(p," FOR SHARE",10)==0) {
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
return false;
}
if (ql>=25) {
@ -340,6 +342,7 @@ bool Query_Info::is_select_NOT_for_update() {
p+=ql-19;
if (strncasecmp(p," LOCK IN SHARE MODE",19)==0) {
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
return false;
}
p=QP;
@ -347,6 +350,7 @@ bool Query_Info::is_select_NOT_for_update() {
if (strncasecmp(p," NOWAIT",7)==0) {
// let simplify. If NOWAIT is used, we assume FOR UPDATE|SHARE is used
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
return false;
/*
if (strcasestr(QP," FOR UPDATE ")==NULL) {
@ -364,6 +368,7 @@ bool Query_Info::is_select_NOT_for_update() {
if (strncasecmp(p," SKIP LOCKED",12)==0) {
// let simplify. If SKIP LOCKED is used, we assume FOR UPDATE|SHARE is used
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
return false;
/*
if (strcasestr(QP," FOR UPDATE ")) {
@ -389,10 +394,12 @@ bool Query_Info::is_select_NOT_for_update() {
if (strcasestr(buf," FOR ")) {
if (strcasestr(buf," FOR UPDATE ")) {
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
return false;
}
if (strcasestr(buf," FOR SHARE ")) {
__sync_fetch_and_add(&MyHGM->status.select_for_update_or_equivalent, 1);
MyHGM->status.p_select_for_update_or_equivalent->Increment();
return false;
}
}
@ -567,6 +574,7 @@ MySQL_Session::~MySQL_Session() {
delete command_counters;
if (session_type==PROXYSQL_SESSION_MYSQL && connections_handler==false && mirror==false) {
__sync_fetch_and_sub(&MyHGM->status.client_connections,1);
MyHGM->status.p_client_connections->Decrement();
}
assert(qpo);
delete qpo;
@ -585,6 +593,7 @@ MySQL_Session::~MySQL_Session() {
}
if (mirror) {
__sync_sub_and_fetch(&GloMTH->status_variables.mirror_sessions_current,1);
GloMTH->status_variables.p_mirror_sessions_current->Decrement();
}
if (ldap_ctx) {
GloMyLdapAuth->ldap_ctx_free(ldap_ctx);
@ -733,12 +742,14 @@ bool MySQL_Session::handler_CommitRollback(PtrSize_t *pkt) {
if (c=='c' || c=='C') {
if (strncasecmp((char *)"commit",(char *)pkt->ptr+5,6)==0) {
__sync_fetch_and_add(&MyHGM->status.commit_cnt, 1);
MyHGM->status.p_commit_cnt->Increment();
ret=true;
}
} else {
if (c=='r' || c=='R') {
if ( strncasecmp((char *)"rollback",(char *)pkt->ptr+5,8)==0 ) {
__sync_fetch_and_add(&MyHGM->status.rollback_cnt, 1);
MyHGM->status.p_rollback_cnt->Increment();
ret=true;
}
}
@ -765,8 +776,10 @@ bool MySQL_Session::handler_CommitRollback(PtrSize_t *pkt) {
l_free(pkt->size,pkt->ptr);
if (c=='c' || c=='C') {
__sync_fetch_and_add(&MyHGM->status.commit_cnt_filtered, 1);
MyHGM->status.p_commit_cnt_filtered->Increment();
} else {
__sync_fetch_and_add(&MyHGM->status.rollback_cnt_filtered, 1);
MyHGM->status.p_rollback_cnt_filtered->Increment();
}
return true;
}
@ -859,6 +872,7 @@ bool MySQL_Session::handler_SetAutocommit(PtrSize_t *pkt) {
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 5, "Setting autocommit to = %d\n", fd);
#endif
__sync_fetch_and_add(&MyHGM->status.autocommit_cnt, 1);
MyHGM->status.p_autocommit_cnt->Increment();
// we immediately process the number of transactions
unsigned int nTrx=NumActiveTransactions();
if (fd==1 && autocommit==true) {
@ -903,6 +917,7 @@ __ret_autocommit_OK:
}
l_free(pkt->size,pkt->ptr);
__sync_fetch_and_add(&MyHGM->status.autocommit_cnt_filtered, 1);
MyHGM->status.p_autocommit_cnt_filtered->Increment();
free(_new_pkt.ptr);
return true;
}
@ -1303,6 +1318,7 @@ bool MySQL_Session::handler_special_queries(PtrSize_t *pkt) {
}
l_free(pkt->size,pkt->ptr);
__sync_fetch_and_add(&MyHGM->status.frontend_set_names, 1);
MyHGM->status.p_frontend_set_names->Increment();
return true;
}
}
@ -1386,6 +1402,7 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C
__sync_sub_and_fetch(&GloMTH->status_variables.mirror_sessions_current,1);
thread->mirror_queue_mysql_sessions->add(newsess);
} else {
GloMTH->status_variables.p_mirror_sessions_current->Increment();
thread->register_session(newsess);
newsess->handler(); // execute immediately
//newsess->to_process=0;
@ -1402,6 +1419,7 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C
}
if (to_cache) {
__sync_sub_and_fetch(&GloMTH->status_variables.mirror_sessions_current,1);
GloMTH->status_variables.p_mirror_sessions_current->Decrement();
thread->mirror_queue_mysql_sessions_cache->add(newsess);
} else {
delete newsess;
@ -1484,6 +1502,7 @@ int MySQL_Session::handler_again___status_RESETTING_CONNECTION() {
int rc=myconn->async_change_user(myds->revents);
if (rc==0) {
__sync_fetch_and_add(&MyHGM->status.backend_change_user, 1);
MyHGM->status.p_backend_change_user->Increment();
//myds->myconn->userinfo->set(client_myds->myconn->userinfo);
myds->myconn->reset();
myconn->async_state_machine=ASYNC_IDLE;
@ -2337,6 +2356,7 @@ bool MySQL_Session::handler_again___status_CHANGING_SCHEMA(int *_rc) {
int rc=myconn->async_select_db(myds->revents);
if (rc==0) {
__sync_fetch_and_add(&MyHGM->status.backend_init_db, 1);
MyHGM->status.p_backend_init_db->Increment();
myds->myconn->userinfo->set(client_myds->myconn->userinfo);
myds->DSS = STATE_MARIADB_GENERIC;
st=previous_status.top();
@ -2558,6 +2578,7 @@ bool MySQL_Session::handler_again___status_CHANGING_USER_SERVER(int *_rc) {
int rc=myconn->async_change_user(myds->revents);
if (rc==0) {
__sync_fetch_and_add(&MyHGM->status.backend_change_user, 1);
MyHGM->status.p_backend_change_user->Increment();
myds->myconn->userinfo->set(client_myds->myconn->userinfo);
myds->myconn->reset();
st=previous_status.top();
@ -4258,6 +4279,7 @@ void MySQL_Session::handler___status_CHANGING_USER_CLIENT___STATE_CLIENT_HANDSHA
GloMyLogger->log_audit_entry(PROXYSQL_MYSQL_CHANGE_USER_ERR, this, NULL);
free(_s);
__sync_fetch_and_add(&MyHGM->status.access_denied_wrong_password, 1);
MyHGM->status.p_access_denied_wrong_password->Increment();
}
}
@ -4412,8 +4434,10 @@ void MySQL_Session::handler___status_CONNECTING_CLIENT___STATE_SERVER_HANDSHAKE(
proxy_warning("mysql-max_connections reached. Returning 'Too many connections'\n");
GloMyLogger->log_audit_entry(PROXYSQL_MYSQL_AUTH_ERR, this, NULL, (char *)"mysql-max_connections reached");
__sync_fetch_and_add(&MyHGM->status.access_denied_max_connections, 1);
MyHGM->status.p_access_denied_max_connections->Increment();
} else { // see issue #794
__sync_fetch_and_add(&MyHGM->status.access_denied_max_user_connections, 1);
MyHGM->status.p_access_denied_max_user_connections->Increment();
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Session=%p , DS=%p . User '%s' has exceeded the 'max_user_connections' resource (current value: %d)\n", this, client_myds, client_myds->myconn->userinfo->username, used_users);
char *a=(char *)"User '%s' has exceeded the 'max_user_connections' resource (current value: %d)";
char *b=(char *)malloc(strlen(a)+strlen(client_myds->myconn->userinfo->username)+16);
@ -4424,6 +4448,7 @@ void MySQL_Session::handler___status_CONNECTING_CLIENT___STATE_SERVER_HANDSHAKE(
free(b);
}
__sync_add_and_fetch(&MyHGM->status.client_connections_aborted,1);
MyHGM->status.p_client_connections_aborted->Increment();
client_myds->DSS=STATE_SLEEP;
} else {
if (
@ -4507,8 +4532,10 @@ void MySQL_Session::handler___status_CONNECTING_CLIENT___STATE_SERVER_HANDSHAKE(
proxy_error("ProxySQL Error: Access denied for user '%s' (using password: %s). SSL is required", client_myds->myconn->userinfo->username, (client_myds->myconn->userinfo->password ? "YES" : "NO"));
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION,8,"Session=%p , DS=%p . Access denied for user '%s' (using password: %s). SSL is required\n", this, client_myds, client_myds->myconn->userinfo->username, (client_myds->myconn->userinfo->password ? "YES" : "NO"));
__sync_add_and_fetch(&MyHGM->status.client_connections_aborted,1);
MyHGM->status.p_client_connections_aborted->Increment();
free(_s);
__sync_fetch_and_add(&MyHGM->status.access_denied_wrong_password, 1);
MyHGM->status.p_access_denied_wrong_password->Increment();
} else {
// we are good!
//client_myds->myprot.generate_pkt_OK(true,NULL,NULL, (is_encrypted ? 3 : 2), 0,0,0,0,NULL);
@ -4589,9 +4616,11 @@ void MySQL_Session::handler___status_CONNECTING_CLIENT___STATE_SERVER_HANDSHAKE(
proxy_error("ProxySQL Error: Access denied for user '%s'@'%s' (using password: %s)\n", client_myds->myconn->userinfo->username, client_addr, (client_myds->myconn->userinfo->password ? "YES" : "NO"));
free(_s);
__sync_fetch_and_add(&MyHGM->status.access_denied_wrong_password, 1);
MyHGM->status.p_access_denied_wrong_password->Increment();
}
GloMyLogger->log_audit_entry(PROXYSQL_MYSQL_AUTH_ERR, this, NULL);
__sync_add_and_fetch(&MyHGM->status.client_connections_aborted,1);
MyHGM->status.p_client_connections_aborted->Increment();
client_myds->DSS=STATE_SLEEP;
}
}
@ -4706,6 +4735,7 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C
proxy_debug(PROXY_DEBUG_MYSQL_COM, 5, "Got COM_INIT_DB packet\n");
if (session_type == PROXYSQL_SESSION_MYSQL) {
__sync_fetch_and_add(&MyHGM->status.frontend_init_db, 1);
MyHGM->status.p_frontend_init_db->Increment();
client_myds->myconn->userinfo->set_schemaname((char *)pkt->ptr+sizeof(mysql_hdr)+1,pkt->size-sizeof(mysql_hdr)-1);
l_free(pkt->size,pkt->ptr);
client_myds->setDSS_STATE_QUERY_SENT_NET();
@ -4733,6 +4763,7 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C
proxy_debug(PROXY_DEBUG_MYSQL_COM, 5, "Got COM_QUERY with USE dbname\n");
if (session_type == PROXYSQL_SESSION_MYSQL) {
__sync_fetch_and_add(&MyHGM->status.frontend_use_db, 1);
MyHGM->status.p_frontend_use_db->Increment();
char *schemaname=strndup((char *)pkt->ptr+sizeof(mysql_hdr)+5,pkt->size-sizeof(mysql_hdr)-5);
char *schemanameptr=trim_spaces_and_quotes_in_place(schemaname);
/*
@ -5065,6 +5096,7 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C
if (__tmp_autocommit >= 0 && autocommit_handled==false) {
int fd = __tmp_autocommit;
__sync_fetch_and_add(&MyHGM->status.autocommit_cnt, 1);
MyHGM->status.p_autocommit_cnt->Increment();
// we immediately process the number of transactions
unsigned int nTrx=NumActiveTransactions();
if (fd==1 && autocommit==true) {
@ -5700,6 +5732,7 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,2,1045,(char *)"28000", _s, true);
free(_s);
__sync_fetch_and_add(&MyHGM->status.access_denied_wrong_password, 1);
MyHGM->status.p_access_denied_wrong_password->Increment();
}
} else {
//FIXME: send an error message saying "not supported" or disconnect

@ -653,6 +653,116 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() {
status_variables.mirror_sessions_current=0;
__global_MySQL_Thread_Variables_version=1;
MLM = new MySQL_Listeners_Manager();
// Create and register prometheus metrics
auto& new_gauge_family {
prometheus::BuildGauge()
.Name("MySQL_Threads_Handler_Gauges")
.Register(*GloVars.prometheus_registry)
};
auto& new_counter_family {
prometheus::BuildCounter()
.Name("MySQL_Threads_Handler_Counters")
.Register(*GloVars.prometheus_registry)
};
// Initialize prometheus metrics
this->status_variables.p_active_transations =
std::addressof(new_gauge_family.Add({{ "id", "Active_Transactions" }}));
this->status_variables.p_non_idle_client_connections =
std::addressof(new_gauge_family.Add({{ "id", "Client_Connections_non_idle" }}));
this->status_variables.p_queries_backends_bytes_sent =
std::addressof(new_counter_family.Add({{ "id", "Queries_backends_bytes_sent" }}));
this->status_variables.p_queries_backends_bytes_recv =
std::addressof(new_counter_family.Add({{ "id", "Queries_backends_bytes_recv" }}));
this->status_variables.p_queries_frontends_bytes_sent =
std::addressof(new_counter_family.Add({{ "id", "Queries_frontends_bytes_sent" }}));
this->status_variables.p_queries_frontends_bytes_recv =
std::addressof(new_counter_family.Add({{ "id", "Queries_frontends_bytes_recv" }}));
this->status_variables.p_query_processor_time =
std::addressof(new_counter_family.Add({{ "id", "Query_Processor_time_nsec" }}));
this->status_variables.p_backend_query_time =
std::addressof(new_counter_family.Add({{ "id", "Backend_query_time_nsec" }}));
this->status_variables.p_mysql_backend_buffers_bytes =
std::addressof(new_gauge_family.Add({{ "id", "mysql_backend_buffers_bytes" }}));
this->status_variables.p_mysql_frontend_buffers_bytes =
std::addressof(new_gauge_family.Add({{ "id", "mysql_frontend_buffers_bytes" }}));
this->status_variables.p_mysql_session_internal_bytes =
std::addressof(new_gauge_family.Add({{ "id", "mysql_session_internal_bytes" }}));
this->status_variables.p_total_backend_stmt_prepare =
std::addressof(new_counter_family.Add({{ "id", "Com_backend_stmt_prepare" }}));
this->status_variables.p_total_backend_stmt_execute =
std::addressof(new_counter_family.Add({{ "id", "Com_backend_stmt_execute" }}));
this->status_variables.p_total_backend_stmt_prepare =
std::addressof(new_counter_family.Add({{ "id", "Com_backend_stmt_prepare" }}));
this->status_variables.p_total_backend_stmt_execute =
std::addressof(new_counter_family.Add({{ "id", "Com_backend_stmt_execute" }}));
this->status_variables.p_total_backend_stmt_close =
std::addressof(new_counter_family.Add({{ "id", "Com_backend_stmt_close" }}));
this->status_variables.p_total_frontend_stmt_prepare =
std::addressof(new_counter_family.Add({{ "id", "Com_frontend_stmt_prepare" }}));
this->status_variables.p_total_frontend_stmt_execute =
std::addressof(new_counter_family.Add({{ "id", "Com_frontend_stmt_execute" }}));
this->status_variables.p_total_frontend_stmt_close =
std::addressof(new_counter_family.Add({{ "id", "Com_frontend_stmt_close" }}));
this->status_variables.p_mirror_sessions_current =
std::addressof(new_gauge_family.Add({{ "id", "Mirror_concurrency" }}));
this->status_variables.p_total_mirror_queue =
std::addressof(new_gauge_family.Add({{ "id", "Mirror_queue_length" }}));
this->status_variables.p_total_queries =
std::addressof(new_counter_family.Add({{ "id", "Questions" }}));
this->status_variables.p_slow_queries =
std::addressof(new_counter_family.Add({{ "id", "Slow_queries" }}));
this->status_variables.p_gtid_queries =
std::addressof(new_counter_family.Add({{ "id", "GTID_consistent_queries" }}));
this->status_variables.p_gtid_session_collected =
std::addressof(new_counter_family.Add({{ "id", "GTID_session_collected" }}));
this->status_variables.p_num_threads =
std::addressof(new_gauge_family.Add({{ "id", "MySQL_Thread_Workers" }}));
this->status_variables.p_ConnPool_get_conn_latency_awareness =
std::addressof(new_counter_family.Add({{ "id", "ConnPool_get_conn_latency_awareness" }}));
this->status_variables.p_ConnPool_get_conn_immediate =
std::addressof(new_counter_family.Add({{ "id", "ConnPool_get_conn_immediate" }}));
this->status_variables.p_ConnPool_get_conn_success =
std::addressof(new_counter_family.Add({{ "id", "ConnPool_get_conn_success" }}));
this->status_variables.p_ConnPool_get_conn_failure =
std::addressof(new_counter_family.Add({{ "id", "ConnPool_get_conn_failure" }}));
this->status_variables.p_ConnPool_get_conn_latency_awareness =
std::addressof(new_counter_family.Add({{ "id", "ConnPool_get_conn_latency_awareness" }}));
this->status_variables.p_generated_error_packets =
std::addressof(new_counter_family.Add({{ "id", "generated_error_packets" }}));
this->status_variables.p_max_connect_timeout =
std::addressof(new_counter_family.Add({{ "id", "max_connect_timeouts" }}));
this->status_variables.p_backend_lagging_during_query =
std::addressof(new_counter_family.Add({{ "id", "backend_lagging_during_query" }}));
this->status_variables.p_backend_offline_during_query =
std::addressof(new_counter_family.Add({{ "id", "backend_offline_during_query" }}));
this->status_variables.p_queries_with_max_lag_ms =
std::addressof(new_counter_family.Add({{ "id", "queries_with_max_lag_ms" }}));
this->status_variables.p_queries_with_max_lag_ms__delayed =
std::addressof(new_counter_family.Add({{ "id", "queries_with_max_lag_ms__delayed" }}));
this->status_variables.p_queries_with_max_lag_ms__total_wait_time_us =
std::addressof(new_counter_family.Add({{ "id", "queries_with_max_lag_ms__total_wait_time_us" }}));
this->status_variables.p_mysql_unexpected_frontend_com_quit =
std::addressof(new_counter_family.Add({{ "id", "mysql_unexpected_frontend_com_quit" }}));
this->status_variables.p_get_hostgroup_locked =
std::addressof(new_counter_family.Add({{ "id", "Client_Connections_hostgroup_locked" }}));
this->status_variables.p_hostgroup_locked_set_cmds =
std::addressof(new_counter_family.Add({{ "id", "hostgroup_locked_set_cmds" }}));
this->status_variables.p_hostgroup_locked_queries =
std::addressof(new_counter_family.Add({{ "id", "hostgroup_locked_queries" }}));
this->status_variables.p_mysql_unexpected_frontend_packets =
std::addressof(new_counter_family.Add({{ "id", "mysql_unexpected_frontend_packets" }}));
this->status_variables.p_aws_aurora_replicas_skipped_during_query =
std::addressof(new_counter_family.Add({{ "id", "aws_aurora_replicas_skipped_during_query" }}));
this->status_variables.p_automatic_detected_sqli =
std::addressof(new_counter_family.Add({{ "id", "automatic_detected_sql_injection" }}));
this->status_variables.p_whitelisted_sqli_fingerprint =
std::addressof(new_counter_family.Add({{ "id", "automatic_detected_sql_injection" }}));
this->status_variables.p_killed_connections =
std::addressof(new_counter_family.Add({{ "id", "mysql_killed_backend_connections" }}));
this->status_variables.p_killed_queries =
std::addressof(new_counter_family.Add({{ "id", "mysql_killed_backend_queries" }}));
}
@ -3520,6 +3630,7 @@ __run_skip_1:
__sync_sub_and_fetch(&GloMTH->status_variables.mirror_sessions_current,1);
goto __mysql_thread_exit_add_mirror; // we can't add more mirror sessions at runtime
} else {
GloMTH->status_variables.p_mirror_sessions_current->Increment();
int idx;
idx=fastrand()%(mirror_queue_mysql_sessions->len);
MySQL_Session *newsess=(MySQL_Session *)mirror_queue_mysql_sessions->remove_index_fast(idx);
@ -3538,6 +3649,7 @@ __run_skip_1:
}
if (to_cache) {
__sync_sub_and_fetch(&GloMTH->status_variables.mirror_sessions_current,1);
GloMTH->status_variables.p_mirror_sessions_current->Decrement();
mirror_queue_mysql_sessions_cache->add(newsess);
} else {
delete newsess;
@ -3787,6 +3899,7 @@ __run_skip_1a:
while (mirror_queue_mysql_sessions_cache->len > mirror_queue_mysql_sessions->len && mirror_queue_mysql_sessions_cache->len > l) {
MySQL_Session *newsess=(MySQL_Session *)mirror_queue_mysql_sessions_cache->remove_index_fast(0);
__sync_add_and_fetch(&GloMTH->status_variables.mirror_sessions_current,1);
GloMTH->status_variables.p_mirror_sessions_current->Increment();
delete newsess;
}
}
@ -4210,6 +4323,7 @@ void MySQL_Thread::process_all_sessions() {
}
if (to_cache) {
__sync_sub_and_fetch(&GloMTH->status_variables.mirror_sessions_current,1);
GloMTH->status_variables.p_mirror_sessions_current->Decrement();
mirror_queue_mysql_sessions_cache->add(sess);
} else {
delete sess;
@ -4630,6 +4744,10 @@ void MySQL_Thread::listener_handle_new_connection(MySQL_Data_Stream *myds, unsig
if (__sync_add_and_fetch(&MyHGM->status.client_connections,1) > mysql_thread___max_connections) {
sess->max_connections_reached=true;
}
// Update metrics
MyHGM->status.p_client_connections_created->Increment();
MyHGM->status.p_client_connections->Increment();
sess->client_myds->client_addrlen=addrlen;
sess->client_myds->client_addr=addr;
@ -5630,6 +5748,8 @@ unsigned long long MySQL_Threads_Handler::get_total_mirror_queue() {
q+=thr->mirror_queue_mysql_sessions->len; // this is a dirty read
}
}
this->status_variables.p_total_mirror_queue->Set(q);
return q;
}
@ -5643,6 +5763,9 @@ unsigned long long MySQL_Threads_Handler::get_total_backend_stmt_prepare() {
q+=__sync_fetch_and_add(&thr->status_variables.backend_stmt_prepare,0);
}
}
const auto& curValue { this->status_variables.p_total_backend_stmt_prepare->Value() };
this->status_variables.p_total_backend_stmt_prepare->Increment(q - curValue);
return q;
}
@ -5656,6 +5779,9 @@ unsigned long long MySQL_Threads_Handler::get_total_backend_stmt_execute() {
q+=__sync_fetch_and_add(&thr->status_variables.backend_stmt_execute,0);
}
}
const auto& curValue { this->status_variables.p_total_backend_stmt_execute->Value() };
this->status_variables.p_total_backend_stmt_execute->Increment(q - curValue);
return q;
}
@ -5669,6 +5795,9 @@ unsigned long long MySQL_Threads_Handler::get_total_backend_stmt_close() {
q+=__sync_fetch_and_add(&thr->status_variables.backend_stmt_close,0);
}
}
const auto& curValue { this->status_variables.p_total_backend_stmt_close->Value() };
this->status_variables.p_total_backend_stmt_close->Increment(q - curValue);
return q;
}
@ -5682,6 +5811,9 @@ unsigned long long MySQL_Threads_Handler::get_total_frontend_stmt_prepare() {
q+=__sync_fetch_and_add(&thr->status_variables.frontend_stmt_prepare,0);
}
}
const auto& curValue { this->status_variables.p_total_frontend_stmt_prepare->Value() };
this->status_variables.p_total_frontend_stmt_prepare->Increment(q - curValue);
return q;
}
@ -5695,6 +5827,9 @@ unsigned long long MySQL_Threads_Handler::get_total_frontend_stmt_execute() {
q+=__sync_fetch_and_add(&thr->status_variables.frontend_stmt_execute,0);
}
}
const auto& curValue { this->status_variables.p_total_frontend_stmt_execute->Value() };
this->status_variables.p_total_frontend_stmt_execute->Increment(q - curValue);
return q;
}
@ -5708,6 +5843,9 @@ unsigned long long MySQL_Threads_Handler::get_total_frontend_stmt_close() {
q+=__sync_fetch_and_add(&thr->status_variables.frontend_stmt_close,0);
}
}
const auto& curValue { this->status_variables.p_total_frontend_stmt_close->Value() };
this->status_variables.p_total_frontend_stmt_close->Increment(q - curValue);
return q;
}
@ -5721,6 +5859,9 @@ unsigned long long MySQL_Threads_Handler::get_total_queries() {
q+=__sync_fetch_and_add(&thr->status_variables.queries,0);
}
}
const auto& curValue { this->status_variables.p_total_queries->Value() };
this->status_variables.p_total_queries->Increment(q - curValue);
return q;
}
@ -5734,6 +5875,9 @@ unsigned long long MySQL_Threads_Handler::get_slow_queries() {
q+=__sync_fetch_and_add(&thr->status_variables.queries_slow,0);
}
}
const auto& curValue { this->status_variables.p_slow_queries->Value() };
this->status_variables.p_slow_queries->Increment(q - curValue);
return q;
}
@ -5747,6 +5891,9 @@ unsigned long long MySQL_Threads_Handler::get_gtid_queries() {
q+=__sync_fetch_and_add(&thr->status_variables.queries_gtid,0);
}
}
const auto& curValue { this->status_variables.p_gtid_queries->Value() };
this->status_variables.p_gtid_queries->Increment(q - curValue);
return q;
}
@ -5760,6 +5907,9 @@ unsigned long long MySQL_Threads_Handler::get_gtid_session_collected() {
q+=__sync_fetch_and_add(&thr->status_variables.gtid_session_collected,0);
}
}
const auto& curValue { this->status_variables.p_gtid_session_collected->Value() };
this->status_variables.p_gtid_session_collected->Increment(q - curValue);
return q;
}
@ -5773,6 +5923,9 @@ unsigned long long MySQL_Threads_Handler::get_queries_backends_bytes_recv() {
q+=__sync_fetch_and_add(&thr->status_variables.queries_backends_bytes_recv,0);
}
}
const auto& curValue { this->status_variables.p_queries_backends_bytes_recv->Value() };
this->status_variables.p_queries_backends_bytes_recv->Increment(q - curValue);
return q;
}
@ -5786,6 +5939,9 @@ unsigned long long MySQL_Threads_Handler::get_queries_backends_bytes_sent() {
q+=__sync_fetch_and_add(&thr->status_variables.queries_backends_bytes_sent,0);
}
}
const auto& curValue { this->status_variables.p_queries_backends_bytes_sent->Value() };
this->status_variables.p_queries_backends_bytes_sent->Increment(q - curValue);
return q;
}
@ -5799,6 +5955,9 @@ unsigned long long MySQL_Threads_Handler::get_queries_frontends_bytes_recv() {
q+=__sync_fetch_and_add(&thr->status_variables.queries_frontends_bytes_recv,0);
}
}
const auto& curValue { this->status_variables.p_queries_frontends_bytes_recv->Value() };
this->status_variables.p_queries_frontends_bytes_recv->Increment(q - curValue);
return q;
}
@ -5812,6 +5971,9 @@ unsigned long long MySQL_Threads_Handler::get_queries_frontends_bytes_sent() {
q+=__sync_fetch_and_add(&thr->status_variables.queries_frontends_bytes_sent,0);
}
}
const auto& curValue { this->status_variables.p_queries_frontends_bytes_sent->Value() };
this->status_variables.p_queries_frontends_bytes_sent->Increment(q - curValue);
return q;
}
@ -5825,6 +5987,8 @@ unsigned int MySQL_Threads_Handler::get_active_transations() {
q+=__sync_fetch_and_add(&thr->status_variables.active_transactions,0);
}
}
this->status_variables.p_active_transations->Set(q);
return q;
}
@ -5839,6 +6003,8 @@ unsigned int MySQL_Threads_Handler::get_non_idle_client_connections() {
q+=__sync_fetch_and_add(&thr->mysql_sessions->len,0);
}
}
status_variables.p_non_idle_client_connections->Set(q);
return q;
}
#endif // IDLE_THREADS
@ -5853,6 +6019,9 @@ unsigned long long MySQL_Threads_Handler::get_query_processor_time() {
q+=__sync_fetch_and_add(&thr->status_variables.query_processor_time,0);
}
}
const auto& cur_val { status_variables.p_query_processor_time->Value() };
status_variables.p_query_processor_time->Increment(q - cur_val);
return q;
}
@ -5866,6 +6035,9 @@ unsigned long long MySQL_Threads_Handler::get_backend_query_time() {
q+=__sync_fetch_and_add(&thr->status_variables.backend_query_time,0);
}
}
const auto& cur_val { status_variables.p_backend_query_time->Value() };
status_variables.p_backend_query_time->Increment(q - cur_val);
return q;
}
@ -5879,6 +6051,8 @@ unsigned long long MySQL_Threads_Handler::get_mysql_backend_buffers_bytes() {
q+=__sync_fetch_and_add(&thr->status_variables.mysql_backend_buffers_bytes,0);
}
}
status_variables.p_mysql_backend_buffers_bytes->Set(q);
return q;
}
@ -5902,6 +6076,8 @@ unsigned long long MySQL_Threads_Handler::get_mysql_frontend_buffers_bytes() {
}
}
#endif // IDLE_THREADS
status_variables.p_mysql_frontend_buffers_bytes->Set(q);
return q;
}
@ -5923,6 +6099,8 @@ unsigned long long MySQL_Threads_Handler::get_mysql_session_internal_bytes() {
}
#endif // IDLE_THREADS
}
status_variables.p_mysql_session_internal_bytes->Set(q);
return q;
}
@ -6089,6 +6267,9 @@ unsigned long long MySQL_Threads_Handler::get_ConnPool_get_conn_latency_awarenes
q+=__sync_fetch_and_add(&thr->status_variables.ConnPool_get_conn_latency_awareness,0);
}
}
const auto& cur_val { status_variables.p_ConnPool_get_conn_latency_awareness->Value() };
status_variables.p_ConnPool_get_conn_latency_awareness->Increment(q - cur_val);
return q;
}
@ -6102,6 +6283,9 @@ unsigned long long MySQL_Threads_Handler::get_ConnPool_get_conn_immediate() {
q+=__sync_fetch_and_add(&thr->status_variables.ConnPool_get_conn_immediate,0);
}
}
const auto& cur_val { status_variables.p_ConnPool_get_conn_immediate->Value() };
status_variables.p_ConnPool_get_conn_immediate->Increment(q - cur_val);
return q;
}
@ -6115,6 +6299,9 @@ unsigned long long MySQL_Threads_Handler::get_ConnPool_get_conn_success() {
q+=__sync_fetch_and_add(&thr->status_variables.ConnPool_get_conn_success,0);
}
}
const auto& cur_val { status_variables.p_ConnPool_get_conn_success->Value() };
status_variables.p_ConnPool_get_conn_success->Increment(q - cur_val);
return q;
}
@ -6128,6 +6315,9 @@ unsigned long long MySQL_Threads_Handler::get_ConnPool_get_conn_failure() {
q+=__sync_fetch_and_add(&thr->status_variables.ConnPool_get_conn_failure,0);
}
}
const auto& cur_val { status_variables.p_ConnPool_get_conn_failure->Value() };
status_variables.p_ConnPool_get_conn_failure->Increment(q - cur_val);
return q;
}
@ -6141,6 +6331,9 @@ unsigned long long MySQL_Threads_Handler::get_generated_pkt_err() {
q+=__sync_fetch_and_add(&thr->status_variables.generated_pkt_err,0);
}
}
const auto& cur_val { status_variables.p_generated_error_packets->Value() };
status_variables.p_generated_error_packets->Increment(q - cur_val);
return q;
}
@ -6154,6 +6347,9 @@ unsigned long long MySQL_Threads_Handler::get_backend_lagging_during_query() {
q+=__sync_fetch_and_add(&thr->status_variables.backend_lagging_during_query,0);
}
}
const auto& cur_val { status_variables.p_backend_lagging_during_query->Value() };
status_variables.p_backend_lagging_during_query->Increment(q - cur_val);
return q;
}
@ -6167,6 +6363,9 @@ unsigned long long MySQL_Threads_Handler::get_backend_offline_during_query() {
q+=__sync_fetch_and_add(&thr->status_variables.backend_offline_during_query,0);
}
}
const auto& cur_val { status_variables.p_backend_offline_during_query->Value() };
status_variables.p_backend_offline_during_query->Increment(q - cur_val);
return q;
}
@ -6180,6 +6379,9 @@ unsigned long long MySQL_Threads_Handler::get_queries_with_max_lag_ms() {
q+=__sync_fetch_and_add(&thr->status_variables.queries_with_max_lag_ms,0);
}
}
const auto& cur_val { status_variables.p_queries_with_max_lag_ms->Value() };
status_variables.p_queries_with_max_lag_ms->Increment(q - cur_val);
return q;
}
@ -6193,6 +6395,9 @@ unsigned long long MySQL_Threads_Handler::get_queries_with_max_lag_ms__delayed()
q+=__sync_fetch_and_add(&thr->status_variables.queries_with_max_lag_ms__delayed,0);
}
}
const auto& cur_val { status_variables.p_queries_with_max_lag_ms__delayed->Value() };
status_variables.p_queries_with_max_lag_ms__delayed->Increment(q - cur_val);
return q;
}
@ -6206,6 +6411,9 @@ unsigned long long MySQL_Threads_Handler::get_queries_with_max_lag_ms__total_wai
q+=__sync_fetch_and_add(&thr->status_variables.queries_with_max_lag_ms__total_wait_time_us,0);
}
}
const auto& cur_val { status_variables.p_queries_with_max_lag_ms__total_wait_time_us->Value() };
status_variables.p_queries_with_max_lag_ms__total_wait_time_us->Increment(q - cur_val);
return q;
}
@ -6219,6 +6427,9 @@ unsigned long long MySQL_Threads_Handler::get_max_connect_timeout() {
q+=__sync_fetch_and_add(&thr->status_variables.max_connect_timeout_err,0);
}
}
const auto& cur_val { status_variables.p_max_connect_timeout->Value() };
status_variables.p_max_connect_timeout->Increment(q - cur_val);
return q;
}
@ -6271,6 +6482,9 @@ unsigned long long MySQL_Threads_Handler::get_unexpected_com_quit() {
q+=__sync_fetch_and_add(&thr->status_variables.unexpected_com_quit,0);
}
}
const auto& cur_val { status_variables.p_mysql_unexpected_frontend_com_quit->Value() };
status_variables.p_mysql_unexpected_frontend_com_quit->Increment(q - cur_val);
return q;
}
@ -6284,6 +6498,9 @@ unsigned long long MySQL_Threads_Handler::get_unexpected_packet() {
q+=__sync_fetch_and_add(&thr->status_variables.unexpected_packet,0);
}
}
const auto& cur_val { status_variables.p_mysql_unexpected_frontend_packets->Value() };
status_variables.p_mysql_unexpected_frontend_packets->Increment(q - cur_val);
return q;
}
@ -6297,6 +6514,9 @@ unsigned long long MySQL_Threads_Handler::get_automatic_detected_sqli() {
q+=__sync_fetch_and_add(&thr->status_variables.automatic_detected_sqli,0);
}
}
const auto& cur_val { status_variables.p_automatic_detected_sqli->Value() };
status_variables.p_automatic_detected_sqli->Increment(q - cur_val);
return q;
}
@ -6310,6 +6530,9 @@ unsigned long long MySQL_Threads_Handler::get_whitelisted_sqli_fingerprint() {
q+=__sync_fetch_and_add(&thr->status_variables.whitelisted_sqli_fingerprint,0);
}
}
const auto& cur_val { status_variables.p_whitelisted_sqli_fingerprint->Value() };
status_variables.p_whitelisted_sqli_fingerprint->Increment(q - cur_val);
return q;
}
@ -6323,6 +6546,9 @@ unsigned long long MySQL_Threads_Handler::get_aws_aurora_replicas_skipped_during
q+=__sync_fetch_and_add(&thr->status_variables.aws_aurora_replicas_skipped_during_query,0);
}
}
const auto& cur_val { status_variables.p_aws_aurora_replicas_skipped_during_query->Value() };
status_variables.p_aws_aurora_replicas_skipped_during_query->Increment(q - cur_val);
return q;
}
@ -6336,6 +6562,9 @@ unsigned long long MySQL_Threads_Handler::get_killed_connections() {
q+=__sync_fetch_and_add(&thr->status_variables.killed_connections,0);
}
}
const auto& cur_val { status_variables.p_killed_connections->Value() };
status_variables.p_killed_connections->Increment(q - cur_val);
return q;
}
@ -6349,6 +6578,9 @@ unsigned long long MySQL_Threads_Handler::get_killed_queries() {
q+=__sync_fetch_and_add(&thr->status_variables.killed_queries,0);
}
}
const auto& cur_val { status_variables.p_killed_queries->Value() };
status_variables.p_killed_queries->Increment(q - cur_val);
return q;
}

Loading…
Cancel
Save