Second iteration on PostgreSQL monitoring POC

This commit packs multiple fixes/improvements:

- Added READONLY support for PostgreSQL.
- Major rework for queries and statements used on monitoring checks:
    + Checks/Actions rewrote for single instance checks.
    + Reuse of prepared statements instance of re-preparation.
- Fixed missing error handling in connection creation state machine.
- Fixed connection rotation in connection pool (now FIFO).
- Added support for configurable batching in scheduler thread, via
  '*_interval_window' variables. These variables allows to define the
  burstiness of the scheduling within the processing interval.
- Added new config variable 'pgsql-monitor_dbname'. Allows to control
  which 'db' will be target by monitoring connections.
- Several fixes for 'poll' timeout computation for worker threads.
- Fixed edge cases for current interval detection.
- Reduced deviation in scheduling intervals computation.
- Refactored and simplified connection event handling.
- Improved error messages for monitoring actions.
- Replaced several invalid uses of 'mysql_thread___monitor_*' in
  favor or new 'mysql_thread___monitor_*' variables.
- Honor '-M' argument for disabling monitoring support.
v3.0-postgres_read_only
Javier Jaramago Fernández 1 year ago
parent 596d5ba21f
commit 100630fba5

@ -838,7 +838,7 @@ class PgSQL_HostGroups_Manager : public Base_HostGroups_Manager<PgSQL_HGC> {
void replication_lag_action_inner(PgSQL_HGC *, const char*, unsigned int, int);
void replication_lag_action(const std::list<replication_lag_server_t>& pgsql_servers);
void read_only_action(char *hostname, int port, int read_only);
void read_only_action_v2(const std::list<read_only_server_t>& pgsql_servers);
void read_only_action_v2(const std::list<read_only_server_t>& pgsql_servers, bool writer_is_also_reader);
unsigned int get_servers_table_version();
void wait_servers_table_version(unsigned, unsigned);
bool shun_and_killall(char *hostname, int port);

@ -14,6 +14,8 @@
#define MONITOR_SQLITE_TABLE_PGSQL_SERVER_PING_LOG "CREATE TABLE pgsql_server_ping_log ( hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 3306 , time_start_us INT NOT NULL DEFAULT 0 , ping_success_time_us INT DEFAULT 0 , ping_error VARCHAR , PRIMARY KEY (hostname, port, time_start_us))"
#define MONITOR_SQLITE_TABLE_PGSQL_SERVER_READ_ONLY_LOG "CREATE TABLE pgsql_server_read_only_log ( hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 3306 , time_start_us INT NOT NULL DEFAULT 0 , success_time_us INT DEFAULT 0 , read_only INT DEFAULT 1 , error VARCHAR , PRIMARY KEY (hostname, port, time_start_us))"
#define MONITOR_SQLITE_TABLE_PGSQL_SERVERS "CREATE TABLE pgsql_servers (hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 3306 , status INT CHECK (status IN (0, 1, 2, 3, 4)) NOT NULL DEFAULT 0 , use_ssl INT CHECK (use_ssl IN(0,1)) NOT NULL DEFAULT 0 , PRIMARY KEY (hostname, port) )"
#define MONITOR_SQLITE_TABLE_PROXYSQL_SERVERS "CREATE TABLE proxysql_servers (hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 6032 , weight INT CHECK (weight >= 0) NOT NULL DEFAULT 0 , comment VARCHAR NOT NULL DEFAULT '' , PRIMARY KEY (hostname, port) )"
@ -35,6 +37,8 @@ struct PgSQL_Monitor {
uint64_t connect_check_OK { 0 };
uint64_t ping_check_ERR { 0 };
uint64_t ping_check_OK { 0 };
uint64_t readonly_check_ERR { 0 };
uint64_t readonly_check_OK { 0 };
///////////////////////////////////////////////////////////////////////////
std::vector<table_def_t> tables_defs_monitor {
@ -45,7 +49,11 @@ struct PgSQL_Monitor {
{
const_cast<char*>("pgsql_server_ping_log"),
const_cast<char*>(MONITOR_SQLITE_TABLE_PGSQL_SERVER_PING_LOG)
}
},
{
const_cast<char*>("pgsql_server_read_only_log"),
const_cast<char*>(MONITOR_SQLITE_TABLE_PGSQL_SERVER_READ_ONLY_LOG)
},
};
std::vector<table_def_t> tables_defs_monitor_internal {

@ -801,9 +801,11 @@ public:
int monitor_history;
int monitor_connect_interval;
int monitor_connect_interval_window;
int monitor_connect_timeout;
//! Monitor ping interval. Unit: 'ms'.
int monitor_ping_interval;
int monitor_ping_interval_window;
int monitor_ping_max_failures;
//! Monitor ping timeout. Unit: 'ms'.
int monitor_ping_timeout;
@ -811,6 +813,7 @@ public:
int monitor_aws_rds_topology_discovery_interval;
//! Monitor read only timeout. Unit: 'ms'.
int monitor_read_only_interval;
int monitor_read_only_interval_window;
//! Monitor read only timeout. Unit: 'ms'.
int monitor_read_only_timeout;
int monitor_read_only_max_timeout_count;
@ -848,6 +851,7 @@ public:
int monitor_local_dns_resolver_queue_maxsize;
char* monitor_username;
char* monitor_password;
char* monitor_dbname;
char* monitor_replication_lag_use_percona_heartbeat;
int ping_interval_server_msec;
int ping_timeout_server;

@ -86,7 +86,8 @@ class ProxySQL_GlobalVariables {
unsigned long long start_time;
bool gdbg;
bool nostart;
bool monitor;
bool my_monitor;
bool pg_monitor;
bool version_check;
#ifdef SO_REUSEPORT
bool reuseport;

@ -648,6 +648,7 @@ enum PROXYSQL_MYSQL_ERR {
ER_PROXYSQL_AWS_HEALTH_CHECK_TIMEOUT = 9018,
ER_PROXYSQL_SRV_NULL_REPLICATION_LAG = 9019,
ER_PROXYSQL_CONNECT_TIMEOUT = 9020,
ER_PROXYSQL_READONLY_TIMEOUT = 9021,
};
enum proxysql_session_type {
@ -1084,16 +1085,21 @@ __thread int pgsql_thread___query_processor_regex;
__thread bool pgsql_thread___monitor_enabled;
__thread int pgsql_thread___monitor_history;
__thread int pgsql_thread___monitor_connect_interval;
__thread int pgsql_thread___monitor_connect_interval_window;
__thread int pgsql_thread___monitor_connect_timeout;
__thread int pgsql_thread___monitor_ping_interval;
__thread int pgsql_thread___monitor_ping_interval_window;
__thread int pgsql_thread___monitor_ping_max_failures;
__thread int pgsql_thread___monitor_ping_timeout;
__thread int pgsql_thread___monitor_read_only_interval;
__thread int pgsql_thread___monitor_read_only_interval_window;
__thread int pgsql_thread___monitor_read_only_timeout;
__thread int pgsql_thread___monitor_read_only_max_timeout_count;
__thread bool pgsql_thread___monitor_writer_is_also_reader;
__thread int pgsql_thread___monitor_threads;
__thread char* pgsql_thread___monitor_username;
__thread char* pgsql_thread___monitor_password;
__thread char* pgsql_thread___monitor_dbname;
//---------------------------
@ -1371,16 +1377,21 @@ extern __thread int pgsql_thread___query_processor_regex;
extern __thread bool pgsql_thread___monitor_enabled;
extern __thread int pgsql_thread___monitor_history;
extern __thread int pgsql_thread___monitor_connect_interval;
extern __thread int pgsql_thread___monitor_connect_interval_window;
extern __thread int pgsql_thread___monitor_connect_timeout;
extern __thread int pgsql_thread___monitor_ping_interval;
extern __thread int pgsql_thread___monitor_ping_interval_window;
extern __thread int pgsql_thread___monitor_ping_max_failures;
extern __thread int pgsql_thread___monitor_ping_timeout;
extern __thread int pgsql_thread___monitor_read_only_interval;
extern __thread int pgsql_thread___monitor_read_only_interval_window;
extern __thread int pgsql_thread___monitor_read_only_timeout;
extern __thread int pgsql_thread___monitor_read_only_max_timeout_count;
extern __thread bool pgsql_thread___monitor_writer_is_also_reader;
extern __thread int pgsql_thread___monitor_threads;
extern __thread char* pgsql_thread___monitor_username;
extern __thread char* pgsql_thread___monitor_password;
extern __thread char* pgsql_thread___monitor_dbname;
//---------------------------

@ -1414,4 +1414,4 @@ int PgSQL_Data_Stream::buffer2array() {
queueIN.pkt.ptr = NULL;
}
return ret;
}
}

@ -3600,7 +3600,9 @@ void PgSQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re
* @param pgsql_servers List of servers having hostname, port and read only value.
*
*/
void PgSQL_HostGroups_Manager::read_only_action_v2(const std::list<read_only_server_t>& pgsql_servers) {
void PgSQL_HostGroups_Manager::read_only_action_v2(
const std::list<read_only_server_t>& pgsql_servers, bool writer_is_also_reader
) {
bool update_pgsql_servers_table = false;
@ -3637,7 +3639,7 @@ void PgSQL_HostGroups_Manager::read_only_action_v2(const std::list<read_only_ser
proxy_debug(PROXY_DEBUG_MONITOR, 5, "Server '%s:%d' found with 'read_only=0', but not found as writer\n", hostname.c_str(), port);
host_server_mapping->copy_if_not_exists(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER);
if (mysql_thread___monitor_writer_is_also_reader == false) {
if (writer_is_also_reader == false) {
// remove node from reader
host_server_mapping->clear(HostGroup_Server_Mapping::Type::READER);
}
@ -3683,7 +3685,7 @@ void PgSQL_HostGroups_Manager::read_only_action_v2(const std::list<read_only_ser
// copy all reader nodes to writer
host_server_mapping->copy_if_not_exists(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER);
if (mysql_thread___monitor_writer_is_also_reader == false) {
if (writer_is_also_reader == false) {
// remove node from reader
host_server_mapping->clear(HostGroup_Server_Mapping::Type::READER);
}

File diff suppressed because it is too large Load Diff

@ -785,14 +785,14 @@ EXECUTION_STATE PgSQL_Protocol::process_handshake_response_packet(unsigned char*
||
((*myds)->sess->session_type == PROXYSQL_SESSION_SQLITE)
) {
if (strcmp((const char*)user, mysql_thread___monitor_username) == 0) {
if (strcmp((const char*)user, pgsql_thread___monitor_username) == 0) {
(*myds)->sess->default_hostgroup = STATS_HOSTGROUP;
(*myds)->sess->default_schema = strdup((char*)"main"); // just the pointer is passed
(*myds)->sess->schema_locked = false;
(*myds)->sess->transaction_persistent = false;
(*myds)->sess->session_fast_forward = false;
(*myds)->sess->user_max_connections = 0;
password = l_strdup(mysql_thread___monitor_password);
password = l_strdup(pgsql_thread___monitor_password);
}
}

@ -4369,12 +4369,12 @@ void PgSQL_Session::handler___status_CONNECTING_CLIENT___STATE_SERVER_HANDSHAKE(
(
client_myds->encrypted == false
&&
strncmp(client_myds->myconn->userinfo->username, mysql_thread___monitor_username, strlen(mysql_thread___monitor_username)) == 0
strncmp(client_myds->myconn->userinfo->username, pgsql_thread___monitor_username, strlen(pgsql_thread___monitor_username)) == 0
)
) // Do not delete this line. See bug #492
) {
if (session_type == PROXYSQL_SESSION_ADMIN) {
if ((default_hostgroup < 0) || (strncmp(client_myds->myconn->userinfo->username, mysql_thread___monitor_username, strlen(mysql_thread___monitor_username)) == 0)) {
if ((default_hostgroup < 0) || (strncmp(client_myds->myconn->userinfo->username, pgsql_thread___monitor_username, strlen(pgsql_thread___monitor_username)) == 0)) {
if (default_hostgroup == STATS_HOSTGROUP) {
session_type = PROXYSQL_SESSION_STATS;
}

@ -311,15 +311,18 @@ static char* pgsql_thread_variables_names[] = {
(char*)"monitor_enabled",
(char*)"monitor_history",
(char*)"monitor_connect_interval",
(char*)"monitor_connect_interval_window",
(char*)"monitor_connect_timeout",
(char*)"monitor_ping_interval",
(char*)"monitor_ping_interval_window",
(char*)"monitor_ping_max_failures",
(char*)"monitor_ping_timeout",
/*
(char*)"monitor_aws_rds_topology_discovery_interval",
(char*)"monitor_read_only_interval",
(char*)"monitor_read_only_interval_window",
(char*)"monitor_read_only_timeout",
(char*)"monitor_read_only_max_timeout_count",
/*
(char*)"monitor_aws_rds_topology_discovery_interval",
(char*)"monitor_replication_lag_group_by_host",
(char*)"monitor_replication_lag_interval",
(char*)"monitor_replication_lag_timeout",
@ -335,6 +338,7 @@ static char* pgsql_thread_variables_names[] = {
*/
(char*)"monitor_username",
(char*)"monitor_password",
(char*)"monitor_dbname",
/*
(char*)"monitor_replication_lag_use_percona_heartbeat",
(char*)"monitor_query_interval",
@ -350,8 +354,8 @@ static char* pgsql_thread_variables_names[] = {
(char*)"monitor_local_dns_cache_refresh_interval",
(char*)"monitor_local_dns_resolver_queue_maxsize",
(char*)"monitor_wait_timeout",
(char*)"monitor_writer_is_also_reader",
*/
(char*)"monitor_writer_is_also_reader",
(char*)"max_allowed_packet",
(char*)"tcp_keepalive_time",
(char*)"use_tcp_keepalive",
@ -932,12 +936,15 @@ PgSQL_Threads_Handler::PgSQL_Threads_Handler() {
variables.monitor_enabled = true;
variables.monitor_history = 7200000; // changed in 2.6.0 : was 600000
variables.monitor_connect_interval = 120000;
variables.monitor_connect_interval_window = 50;
variables.monitor_connect_timeout = 600;
variables.monitor_ping_interval = 8000;
variables.monitor_ping_interval_window = 10;
variables.monitor_ping_max_failures = 3;
variables.monitor_ping_timeout = 1000;
variables.monitor_aws_rds_topology_discovery_interval=1000;
variables.monitor_read_only_interval = 1000;
variables.monitor_read_only_interval_window = 10;
variables.monitor_read_only_timeout = 800;
variables.monitor_read_only_max_timeout_count = 3;
variables.monitor_replication_lag_group_by_host = false;
@ -966,6 +973,7 @@ PgSQL_Threads_Handler::PgSQL_Threads_Handler() {
variables.monitor_local_dns_resolver_queue_maxsize = 128;
variables.monitor_username = strdup((char*)"monitor");
variables.monitor_password = strdup((char*)"monitor");
variables.monitor_dbname = strdup((char*)"postgres");
/* TODO: Remove
variables.monitor_replication_lag_use_percona_heartbeat = strdup((char*)"");
*/
@ -1181,6 +1189,7 @@ char* PgSQL_Threads_Handler::get_variable_string(char* name) {
if (!strncmp(name, "monitor_", 8)) {
if (!strcmp(name, "monitor_username")) return strdup(variables.monitor_username);
if (!strcmp(name, "monitor_password")) return strdup(variables.monitor_password);
if (!strcmp(name, "monitor_dbname")) return strdup(variables.monitor_dbname);
/*
if (!strcmp(name, "monitor_replication_lag_use_percona_heartbeat")) return strdup(variables.monitor_replication_lag_use_percona_heartbeat);
*/
@ -1504,6 +1513,7 @@ char* PgSQL_Threads_Handler::get_variable(char* name) { // this is the public fu
if (!strncasecmp(name, "monitor_", 8)) {
if (!strcasecmp(name, "monitor_username")) return strdup(variables.monitor_username);
if (!strcasecmp(name, "monitor_password")) return strdup(variables.monitor_password);
if (!strcasecmp(name, "monitor_dbname")) return strdup(variables.monitor_dbname);
/*
if (!strcasecmp(name, "monitor_replication_lag_use_percona_heartbeat")) return strdup(variables.monitor_replication_lag_use_percona_heartbeat);
*/
@ -1615,6 +1625,11 @@ bool PgSQL_Threads_Handler::set_variable(char* name, const char* value) { // thi
variables.monitor_password = strdup(value);
return true;
}
if (!strcasecmp(name, "monitor_dbname")) {
free(variables.monitor_dbname);
variables.monitor_dbname = strdup(value);
return true;
}
if (!strcasecmp(name, "monitor_replication_lag_use_percona_heartbeat")) {
if (vallen == 0) { // empty string
free(variables.monitor_replication_lag_use_percona_heartbeat);
@ -2079,9 +2094,11 @@ char** PgSQL_Threads_Handler::get_variables_list() {
VariablesPointers_int["monitor_history"] = make_tuple(&variables.monitor_history, 1000, 7 * 24 * 3600 * 1000, false);
VariablesPointers_int["monitor_connect_interval"] = make_tuple(&variables.monitor_connect_interval, 100, 7 * 24 * 3600 * 1000, false);
VariablesPointers_int["monitor_connect_interval_window"] = make_tuple(&variables.monitor_connect_interval_window, 0, 100, false);
VariablesPointers_int["monitor_connect_timeout"] = make_tuple(&variables.monitor_connect_timeout, 100, 600 * 1000, false);
VariablesPointers_int["monitor_ping_interval"] = make_tuple(&variables.monitor_ping_interval, 100, 7 * 24 * 3600 * 1000, false);
VariablesPointers_int["monitor_ping_interval_window"] = make_tuple(&variables.monitor_ping_interval_window, 0, 100, false);
VariablesPointers_int["monitor_ping_timeout"] = make_tuple(&variables.monitor_ping_timeout, 100, 600 * 1000, false);
VariablesPointers_int["monitor_ping_max_failures"] = make_tuple(&variables.monitor_ping_max_failures, 1, 1000 * 1000, false);
@ -2089,6 +2106,7 @@ char** PgSQL_Threads_Handler::get_variables_list() {
VariablesPointers_int["monitor_aws_rds_topology_discovery_interval"] = make_tuple(&variables.monitor_aws_rds_topology_discovery_interval, 1, 100000, false);
*/
VariablesPointers_int["monitor_read_only_interval"] = make_tuple(&variables.monitor_read_only_interval, 100, 7 * 24 * 3600 * 1000, false);
VariablesPointers_int["monitor_read_only_interval_window"] = make_tuple(&variables.monitor_read_only_interval_window, 0, 100, false);
VariablesPointers_int["monitor_read_only_timeout"] = make_tuple(&variables.monitor_read_only_timeout, 100, 600 * 1000, false);
VariablesPointers_int["monitor_read_only_max_timeout_count"] = make_tuple(&variables.monitor_read_only_max_timeout_count, 1, 1000 * 1000, false);
/*
@ -2590,6 +2608,7 @@ void PgSQL_Threads_Handler::flush_client_host_cache() {
PgSQL_Threads_Handler::~PgSQL_Threads_Handler() {
if (variables.monitor_username) { free(variables.monitor_username); variables.monitor_username = NULL; }
if (variables.monitor_password) { free(variables.monitor_password); variables.monitor_password = NULL; }
if (variables.monitor_dbname) { free(variables.monitor_dbname); variables.monitor_dbname = NULL; }
if (variables.monitor_replication_lag_use_percona_heartbeat) {
free(variables.monitor_replication_lag_use_percona_heartbeat);
variables.monitor_replication_lag_use_percona_heartbeat = NULL;
@ -2722,13 +2741,16 @@ PgSQL_Thread::~PgSQL_Thread() {
if (pgsql_thread___monitor_username) { free(pgsql_thread___monitor_username); pgsql_thread___monitor_username = NULL; }
if (pgsql_thread___monitor_password) { free(pgsql_thread___monitor_password); pgsql_thread___monitor_password = NULL; }
if (pgsql_thread___monitor_dbname) { free(pgsql_thread___monitor_dbname); pgsql_thread___monitor_dbname = NULL; }
/*
if (mysql_thread___monitor_username) { free(mysql_thread___monitor_username); mysql_thread___monitor_username = NULL; }
if (mysql_thread___monitor_password) { free(mysql_thread___monitor_password); mysql_thread___monitor_password = NULL; }
if (mysql_thread___monitor_replication_lag_use_percona_heartbeat) {
free(mysql_thread___monitor_replication_lag_use_percona_heartbeat);
mysql_thread___monitor_replication_lag_use_percona_heartbeat = NULL;
}
*/
//if (pgsql_thread___default_schema) { free(pgsql_thread___default_schema); pgsql_thread___default_schema = NULL; }
if (pgsql_thread___keep_multiplexing_variables) { free(pgsql_thread___keep_multiplexing_variables); pgsql_thread___keep_multiplexing_variables = NULL; }
if (pgsql_thread___firewall_whitelist_errormsg) { free(pgsql_thread___firewall_whitelist_errormsg); pgsql_thread___firewall_whitelist_errormsg = NULL; }
@ -3799,36 +3821,39 @@ void PgSQL_Thread::refresh_variables() {
mysql_thread___max_stmts_per_connection = GloPTH->get_variable_int((char*)"max_stmts_per_connection");
mysql_thread___max_stmts_cache = GloPTH->get_variable_int((char*)"max_stmts_cache");
*/
if (mysql_thread___monitor_username) free(mysql_thread___monitor_username);
mysql_thread___monitor_username = GloPTH->get_variable_string((char*)"monitor_username");
if (mysql_thread___monitor_password) free(mysql_thread___monitor_password);
mysql_thread___monitor_password = GloPTH->get_variable_string((char*)"monitor_password");
/*if (mysql_thread___monitor_replication_lag_use_percona_heartbeat) free(mysql_thread___monitor_replication_lag_use_percona_heartbeat);
if (mysql_thread___monitor_replication_lag_use_percona_heartbeat) free(mysql_thread___monitor_replication_lag_use_percona_heartbeat);
mysql_thread___monitor_replication_lag_use_percona_heartbeat = GloPTH->get_variable_string((char*)"monitor_replication_lag_use_percona_heartbeat");
mysql_thread___monitor_wait_timeout = (bool)GloPTH->get_variable_int((char*)"monitor_wait_timeout");
mysql_thread___monitor_writer_is_also_reader = (bool)GloPTH->get_variable_int((char*)"monitor_writer_is_also_reader");
*/
pgsql_thread___monitor_writer_is_also_reader = (bool)GloPTH->get_variable_int((char*)"monitor_writer_is_also_reader");
pgsql_thread___monitor_enabled = (bool)GloPTH->get_variable_int((char*)"monitor_enabled");
pgsql_thread___monitor_history = GloPTH->get_variable_int((char*)"monitor_history");
pgsql_thread___monitor_connect_interval = GloPTH->get_variable_int((char*)"monitor_connect_interval");
pgsql_thread___monitor_connect_interval_window = GloPTH->get_variable_int((char*)"monitor_connect_interval_window");
pgsql_thread___monitor_connect_timeout = GloPTH->get_variable_int((char*)"monitor_connect_timeout");
pgsql_thread___monitor_ping_interval = GloPTH->get_variable_int((char*)"monitor_ping_interval");
pgsql_thread___monitor_ping_interval_window = GloPTH->get_variable_int((char*)"monitor_ping_interval_window");
pgsql_thread___monitor_ping_max_failures = GloPTH->get_variable_int((char*)"monitor_ping_max_failures");
pgsql_thread___monitor_ping_timeout = GloPTH->get_variable_int((char*)"monitor_ping_timeout");
pgsql_thread___monitor_read_only_interval = GloPTH->get_variable_int((char*)"monitor_read_only_interval");
pgsql_thread___monitor_read_only_interval_window = GloPTH->get_variable_int((char*)"monitor_read_only_interval_window");
pgsql_thread___monitor_read_only_timeout = GloPTH->get_variable_int((char*)"monitor_read_only_timeout");
pgsql_thread___monitor_read_only_max_timeout_count = GloPTH->get_variable_int((char*)"monitor_read_only_max_timeout_count");
pgsql_thread___monitor_threads = GloPTH->get_variable_int((char*)"monitor_threads");
if (pgsql_thread___monitor_username) free(pgsql_thread___monitor_username);
pgsql_thread___monitor_username = GloPTH->get_variable_string((char*)"monitor_username");
if (pgsql_thread___monitor_password) free(pgsql_thread___monitor_password);
pgsql_thread___monitor_password = GloPTH->get_variable_string((char*)"monitor_password");
if (pgsql_thread___monitor_dbname) free(pgsql_thread___monitor_dbname);
pgsql_thread___monitor_dbname = GloPTH->get_variable_string((char*)"monitor_dbname");
/*
mysql_thread___monitor_aws_rds_topology_discovery_interval = GloPTH->get_variable_int((char *)"monitor_aws_rds_topology_discovery_interval");
mysql_thread___monitor_read_only_max_timeout_count = GloPTH->get_variable_int((char*)"monitor_read_only_max_timeout_count");
mysql_thread___monitor_replication_lag_group_by_host = (bool)GloPTH->get_variable_int((char*)"monitor_replication_lag_group_by_host");
mysql_thread___monitor_replication_lag_interval = GloPTH->get_variable_int((char*)"monitor_replication_lag_interval");
mysql_thread___monitor_replication_lag_timeout = GloPTH->get_variable_int((char*)"monitor_replication_lag_timeout");
@ -4437,19 +4462,19 @@ SQLite3_result* PgSQL_Threads_Handler::SQL3_GlobalStatus(bool _memory) {
pta[1] = buf;
result->add_row(pta);
}
/*
{
pta[0] = (char*)"MySQL_Monitor_read_only_check_OK";
sprintf(buf, "%llu", GloMyMon->read_only_check_OK);
pta[0] = (char*)"PgSQL_Monitor_read_only_check_OK";
sprintf(buf, "%lu", GloPgMon->readonly_check_OK);
pta[1] = buf;
result->add_row(pta);
}
{
pta[0] = (char*)"MySQL_Monitor_read_only_check_ERR";
sprintf(buf, "%llu", GloMyMon->read_only_check_ERR);
pta[0] = (char*)"PgSQL_Monitor_read_only_check_ERR";
sprintf(buf, "%lu", GloPgMon->readonly_check_ERR);
pta[1] = buf;
result->add_row(pta);
}
/*
{
pta[0] = (char*)"MySQL_Monitor_replication_lag_check_OK";
sprintf(buf, "%llu", GloMyMon->replication_lag_check_OK);

@ -869,7 +869,7 @@ void ProxySQL_Node_Entry::set_checksums(MYSQL_RES *_r) {
mysql_servers_sync_algorithm mysql_server_sync_algo = (mysql_servers_sync_algorithm)__sync_fetch_and_add(&GloProxyCluster->cluster_mysql_servers_sync_algorithm, 0);
if (mysql_server_sync_algo == mysql_servers_sync_algorithm::auto_select) {
mysql_server_sync_algo = (GloVars.global.monitor == false) ?
mysql_server_sync_algo = (GloVars.global.my_monitor == false) ?
mysql_servers_sync_algorithm::runtime_mysql_servers_and_mysql_servers_v2 : mysql_servers_sync_algorithm::mysql_servers_v2;
}

@ -197,7 +197,8 @@ ProxySQL_GlobalVariables::ProxySQL_GlobalVariables() :
global.gdbg=false;
global.nostart=false;
global.foreground=false;
global.monitor=true;
global.my_monitor=true;
global.pg_monitor=true;
#ifdef IDLE_THREADS
global.idle_threads=false;
#endif /* IDLE_THREADS */
@ -481,7 +482,8 @@ void ProxySQL_GlobalVariables::process_opts_post() {
}
if (opt->isSet("-M")) {
global.monitor=false;
global.my_monitor=false;
global.pg_monitor=false;
}
#ifdef SO_REUSEPORT

@ -1414,12 +1414,20 @@ void ProxySQL_Main_init_phase3___start_all() {
std::cerr << "Main phase3 : SQLite3 Server initialized in ";
#endif
}
if (GloVars.global.monitor==true)
if (GloVars.global.my_monitor==true)
{
cpu_timer t;
ProxySQL_Main_init_MySQL_Monitor_module();
#ifdef DEBUG
std::cerr << "Main phase3 : MySQL Monitor initialized in ";
#endif
}
if (GloVars.global.pg_monitor==true)
{
cpu_timer t;
pgsql_monitor_thread = new std::thread(&PgSQL_monitor_scheduler_thread);
#ifdef DEBUG
std::cerr << "Main phase3 : PgSQL Monitor initialized in ";
#endif
}
#ifdef PROXYSQLCLICKHOUSE
@ -1447,8 +1455,6 @@ void ProxySQL_Main_init_phase3___start_all() {
// Load the config not previously loaded for these modules
GloAdmin->load_http_server();
GloAdmin->load_restapi_server();
pgsql_monitor_thread = new std::thread(&PgSQL_monitor_scheduler_thread);
}

Loading…
Cancel
Save