Code cleanup on MySQL_HostGroups_Manager

Some rework to try to reduce duplicated code
pull/4078/head
René Cannaò 3 years ago
parent 5fc840b990
commit 71e2510ef6

@ -18,6 +18,11 @@
#include "ev.h"
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
#ifdef DEBUG
/* */
// Enabling STRESSTEST_POOL ProxySQL will do a lot of loops in the connection pool
@ -570,6 +575,8 @@ class MySQL_HostGroups_Manager {
void wrunlock();
int servers_add(SQLite3_result *resultset);
bool commit(SQLite3_result* runtime_mysql_servers = nullptr, const std::string& checksum = "", const time_t epoch = 0);
void commit_update_checksums_from_tables(SpookyHash& myhash, bool& init);
void CUCFT1(SpookyHash& myhash, bool& init, const string& TableName, const string& ColumnName); // used by commit_update_checksums_from_tables()
/**
* @brief Store the resultset for the 'runtime_mysql_servers' table set that have been loaded to runtime.
@ -583,23 +590,13 @@ class MySQL_HostGroups_Manager {
* Cluster to propagate current config.
* @param The resulset to be stored replacing the current one.
*/
void save_incoming_replication_hostgroups(SQLite3_result *);
void save_incoming_group_replication_hostgroups(SQLite3_result *);
void save_incoming_galera_hostgroups(SQLite3_result *);
void save_incoming_aws_aurora_hostgroups(SQLite3_result *);
SQLite3_result* get_current_mysql_servers_inner();
SQLite3_result* get_current_mysql_replication_hostgroups_inner();
SQLite3_result* get_current_mysql_group_replication_hostgroups_inner();
SQLite3_result* get_current_mysql_galera_hostgroups();
SQLite3_result* get_current_mysql_aws_aurora_hostgroups();
void save_incoming_mysql_table(SQLite3_result *, const string&);
SQLite3_result* get_current_mysql_table(const string& name);
SQLite3_result * execute_query(char *query, char **error);
SQLite3_result *dump_table_mysql_servers();
SQLite3_result *dump_table_mysql_replication_hostgroups();
SQLite3_result *dump_table_mysql_group_replication_hostgroups();
SQLite3_result *dump_table_mysql_galera_hostgroups();
SQLite3_result *dump_table_mysql_aws_aurora_hostgroups();
SQLite3_result *dump_table_mysql(const string&);
/**
* @brief Update the public member resulset 'mysql_servers_to_monitor'. This resulset should contain the latest
* 'mysql_servers' present in 'MySQL_HostGroups_Manager' db, which are not 'OFFLINE_HARD'. The resulset

@ -3,7 +3,10 @@
#include "proxysql.h"
#include "cpp.h"
#include "proxysql_atomic.h"
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
ClickHouse_Authentication::ClickHouse_Authentication() {
#ifdef DEBUG

@ -23,7 +23,10 @@
#include <resolv.h>
#include <arpa/inet.h>
#include <pthread.h>
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
#include <fcntl.h>
#include <sys/utsname.h>

@ -5,7 +5,10 @@
#include "MySQL_Authentication.hpp"
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
MySQL_Authentication::MySQL_Authentication() {
#ifdef DEBUG

@ -1,7 +1,6 @@
#include "MySQL_HostGroups_Manager.h"
#include "proxysql.h"
#include "cpp.h"
#include "SpookyV2.h"
#include "MySQL_PreparedStatement.h"
#include "MySQL_Data_Stream.h"
@ -1560,6 +1559,34 @@ SQLite3_result * MySQL_HostGroups_Manager::execute_query(char *query, char **err
return resultset;
}
void MySQL_HostGroups_Manager::CUCFT1(SpookyHash& myhash, bool& init, const string& TableName, const string& ColumnName) {
char *error=NULL;
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
string query = "SELECT * FROM " + TableName + " ORDER BY " + ColumnName;
mydb->execute_statement(query.c_str(), &error , &cols , &affected_rows , &resultset);
if (resultset) {
if (resultset->rows_count) {
if (init == false) {
init = true;
myhash.Init(19,3);
}
uint64_t hash1_ = resultset->raw_checksum();
myhash.Update(&hash1_, sizeof(hash1_));
proxy_info("Checksum for table %s is %lu\n", TableName.c_str(), hash1_);
}
delete resultset;
}
}
void MySQL_HostGroups_Manager::commit_update_checksums_from_tables(SpookyHash& myhash, bool& init) {
CUCFT1(myhash,init,"mysql_replication_hostgroups","writer_hostgroup");
CUCFT1(myhash,init,"mysql_group_replication_hostgroups","writer_hostgroup");
CUCFT1(myhash,init,"mysql_galera_hostgroups","writer_hostgroup");
CUCFT1(myhash,init,"mysql_aws_aurora_hostgroups","writer_hostgroup");
}
bool MySQL_HostGroups_Manager::commit(
SQLite3_result* runtime_mysql_servers, const std::string& checksum, const time_t epoch
) {
@ -1861,86 +1888,9 @@ bool MySQL_HostGroups_Manager::commit(
delete resultset;
}
}
{
char *error=NULL;
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
char *query=(char *)"SELECT * FROM mysql_replication_hostgroups ORDER BY writer_hostgroup";
mydb->execute_statement(query, &error , &cols , &affected_rows , &resultset);
if (resultset) {
if (resultset->rows_count) {
if (init == false) {
init = true;
myhash.Init(19,3);
}
uint64_t hash1_ = resultset->raw_checksum();
myhash.Update(&hash1_, sizeof(hash1_));
proxy_info("Checksum for table %s is %lu\n", "mysql_replication_hostgroups", hash1_);
}
delete resultset;
}
}
{
char *error=NULL;
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
char *query=(char *)"SELECT * FROM mysql_group_replication_hostgroups ORDER BY writer_hostgroup";
mydb->execute_statement(query, &error , &cols , &affected_rows , &resultset);
if (resultset) {
if (resultset->rows_count) {
if (init == false) {
init = true;
myhash.Init(19,3);
}
uint64_t hash1_ = resultset->raw_checksum();
myhash.Update(&hash1_, sizeof(hash1_));
proxy_info("Checksum for table %s is %lu\n", "mysql_group_replication_hostgroups", hash1_);
}
delete resultset;
}
}
{
char *error=NULL;
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
char *query=(char *)"SELECT * FROM mysql_galera_hostgroups ORDER BY writer_hostgroup";
mydb->execute_statement(query, &error , &cols , &affected_rows , &resultset);
if (resultset) {
if (resultset->rows_count) {
if (init == false) {
init = true;
myhash.Init(19,3);
}
uint64_t hash1_ = resultset->raw_checksum();
myhash.Update(&hash1_, sizeof(hash1_));
proxy_info("Checksum for table %s is %lu\n", "mysql_galera_hostgroups", hash1_);
}
delete resultset;
}
}
{
char *error=NULL;
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
char *query=(char *)"SELECT * FROM mysql_aws_aurora_hostgroups ORDER BY writer_hostgroup";
mydb->execute_statement(query, &error , &cols , &affected_rows , &resultset);
if (resultset) {
if (resultset->rows_count) {
if (init == false) {
init = true;
myhash.Init(19,3);
}
uint64_t hash1_ = resultset->raw_checksum();
myhash.Update(&hash1_, sizeof(hash1_));
proxy_info("Checksum for table %s is %lu\n", "mysql_aws_aurora_hostgroups", hash1_);
}
delete resultset;
}
}
commit_update_checksums_from_tables(myhash, init);
if (init == true) {
myhash.Final(&hash1, &hash2);
}
@ -2481,26 +2431,6 @@ void MySQL_HostGroups_Manager::generate_mysql_galera_hostgroups_table() {
pthread_mutex_unlock(&Galera_Info_mutex);
}
SQLite3_result * MySQL_HostGroups_Manager::dump_table_mysql_servers() {
wrlock();
// purge table
purge_mysql_servers_table();
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "DELETE FROM mysql_servers\n");
mydb->execute("DELETE FROM mysql_servers");
generate_mysql_servers_table();
char *error=NULL;
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "%s\n", MYHGM_GEN_ADMIN_RUNTIME_SERVERS);
mydb->execute_statement(MYHGM_GEN_ADMIN_RUNTIME_SERVERS, &error , &cols , &affected_rows , &resultset);
wrunlock();
return resultset;
}
void MySQL_HostGroups_Manager::update_table_mysql_servers_for_monitor(bool lock) {
if (lock) {
wrlock();
@ -2533,58 +2463,39 @@ void MySQL_HostGroups_Manager::update_table_mysql_servers_for_monitor(bool lock)
MySQL_Monitor::trigger_dns_cache_update();
}
SQLite3_result * MySQL_HostGroups_Manager::dump_table_mysql_replication_hostgroups() {
wrlock();
char *error=NULL;
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
char *query=(char *)"SELECT writer_hostgroup, reader_hostgroup, check_type, comment FROM mysql_replication_hostgroups";
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "%s\n", query);
mydb->execute_statement(query, &error , &cols , &affected_rows , &resultset);
wrunlock();
return resultset;
}
SQLite3_result * MySQL_HostGroups_Manager::dump_table_mysql_group_replication_hostgroups() {
wrlock();
char *error=NULL;
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
char *query=(char *)"SELECT writer_hostgroup,backup_writer_hostgroup,reader_hostgroup,offline_hostgroup,active,max_writers,writer_is_also_reader,max_transactions_behind,comment FROM mysql_group_replication_hostgroups";
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "%s\n", query);
mydb->execute_statement(query, &error , &cols , &affected_rows , &resultset);
wrunlock();
return resultset;
}
SQLite3_result * MySQL_HostGroups_Manager::dump_table_mysql_galera_hostgroups() {
SQLite3_result * MySQL_HostGroups_Manager::dump_table_mysql(const string& name) {
char * query = (char *)"";
if (name == "mysql_aws_aurora_hostgroups") {
query=(char *)"SELECT writer_hostgroup,reader_hostgroup,active,aurora_port,domain_name,max_lag_ms,"
"check_interval_ms,check_timeout_ms,writer_is_also_reader,new_reader_weight,add_lag_ms,min_lag_ms,lag_num_checks,comment FROM mysql_aws_aurora_hostgroups";
} else if (name == "mysql_galera_hostgroups") {
query=(char *)"SELECT writer_hostgroup,backup_writer_hostgroup,reader_hostgroup,offline_hostgroup,active,max_writers,writer_is_also_reader,max_transactions_behind,comment FROM mysql_galera_hostgroups";
} else if (name == "mysql_group_replication_hostgroups") {
query=(char *)"SELECT writer_hostgroup,backup_writer_hostgroup,reader_hostgroup,offline_hostgroup,active,max_writers,writer_is_also_reader,max_transactions_behind,comment FROM mysql_group_replication_hostgroups";
} else if (name == "mysql_replication_hostgroups") {
query=(char *)"SELECT writer_hostgroup, reader_hostgroup, check_type, comment FROM mysql_replication_hostgroups";
} else if (name == "mysql_servers") {
query = (char *)MYHGM_GEN_ADMIN_RUNTIME_SERVERS;
} else {
assert(0);
}
wrlock();
if (name == "mysql_servers") {
purge_mysql_servers_table();
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "DELETE FROM mysql_servers\n");
mydb->execute("DELETE FROM mysql_servers");
generate_mysql_servers_table();
}
char *error=NULL;
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
char *query=(char *)"SELECT writer_hostgroup,backup_writer_hostgroup,reader_hostgroup,offline_hostgroup,active,max_writers,writer_is_also_reader,max_transactions_behind,comment FROM mysql_galera_hostgroups";
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "%s\n", query);
mydb->execute_statement(query, &error , &cols , &affected_rows , &resultset);
wrunlock();
return resultset;
}
SQLite3_result * MySQL_HostGroups_Manager::dump_table_mysql_aws_aurora_hostgroups() {
wrlock();
char *error=NULL;
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
char *query=(char *)"SELECT writer_hostgroup,reader_hostgroup,active,aurora_port,domain_name,max_lag_ms,"
"check_interval_ms,check_timeout_ms,writer_is_also_reader,new_reader_weight,add_lag_ms,min_lag_ms,lag_num_checks,comment FROM mysql_aws_aurora_hostgroups";
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "%s\n", query);
mydb->execute_statement(query, &error , &cols , &affected_rows , &resultset);
wrunlock();
return resultset;
}
MyHGC * MySQL_HostGroups_Manager::MyHGC_create(unsigned int _hid) {
MyHGC *myhgc=new MyHGC(_hid);
@ -3735,6 +3646,26 @@ __exit_get_multiple_idle_connections:
return num_conn_current;
}
void MySQL_HostGroups_Manager::save_incoming_mysql_table(SQLite3_result *s, const string& name) {
SQLite3_result ** inc = NULL;
if (name == "mysql_aws_aurora_hostgroups") {
inc = &incoming_aws_aurora_hostgroups;
} else if (name == "mysql_galeran_hostgroups") {
inc = &incoming_galera_hostgroups;
} else if (name == "mysql_group_replication_hostgroups") {
inc = &incoming_group_replication_hostgroups;
} else if (name == "mysql_replication_hostgroups") {
inc = &incoming_replication_hostgroups;
} else {
assert(0);
}
if (*inc != nullptr) {
delete *inc;
*inc = nullptr;
}
*inc = s;
}
void MySQL_HostGroups_Manager::save_runtime_mysql_servers(SQLite3_result *s) {
if (runtime_mysql_servers) {
delete runtime_mysql_servers;
@ -3743,57 +3674,24 @@ void MySQL_HostGroups_Manager::save_runtime_mysql_servers(SQLite3_result *s) {
runtime_mysql_servers=s;
}
void MySQL_HostGroups_Manager::save_incoming_replication_hostgroups(SQLite3_result *s) {
if (incoming_replication_hostgroups) {
delete incoming_replication_hostgroups;
incoming_replication_hostgroups = nullptr;
}
incoming_replication_hostgroups=s;
}
void MySQL_HostGroups_Manager::save_incoming_group_replication_hostgroups(SQLite3_result *s) {
if (incoming_group_replication_hostgroups) {
delete incoming_group_replication_hostgroups;
incoming_group_replication_hostgroups = NULL;
}
incoming_group_replication_hostgroups=s;
}
void MySQL_HostGroups_Manager::save_incoming_galera_hostgroups(SQLite3_result *s) {
if (incoming_galera_hostgroups) {
delete incoming_galera_hostgroups;
incoming_galera_hostgroups = NULL;
}
incoming_galera_hostgroups=s;
}
void MySQL_HostGroups_Manager::save_incoming_aws_aurora_hostgroups(SQLite3_result *s) {
if (incoming_aws_aurora_hostgroups) {
delete incoming_aws_aurora_hostgroups;
incoming_aws_aurora_hostgroups = NULL;
SQLite3_result* MySQL_HostGroups_Manager::get_current_mysql_table(const string& name) {
if (name == "mysql_aws_aurora_hostgroups") {
return this->incoming_aws_aurora_hostgroups;
} else if (name == "mysql_galera_hostgroups") {
return this->incoming_galera_hostgroups;
} else if (name == "mysql_group_replication_hostgroups") {
return this->incoming_group_replication_hostgroups;
} else if (name == "mysql_replication_hostgroups") {
return this->incoming_replication_hostgroups;
} else if (name == "mysql_serverss") {
return this->runtime_mysql_servers;
} else {
assert(0);
}
incoming_aws_aurora_hostgroups=s;
}
SQLite3_result* MySQL_HostGroups_Manager::get_current_mysql_servers_inner() {
return this->runtime_mysql_servers;
}
SQLite3_result* MySQL_HostGroups_Manager::get_current_mysql_replication_hostgroups_inner() {
return this->incoming_replication_hostgroups;
return NULL;
}
SQLite3_result* MySQL_HostGroups_Manager::get_current_mysql_group_replication_hostgroups_inner() {
return this->incoming_group_replication_hostgroups;
}
SQLite3_result* MySQL_HostGroups_Manager::get_current_mysql_galera_hostgroups() {
return this->incoming_galera_hostgroups;
}
SQLite3_result* MySQL_HostGroups_Manager::get_current_mysql_aws_aurora_hostgroups() {
return this->incoming_aws_aurora_hostgroups;
}
SQLite3_result * MySQL_HostGroups_Manager::SQL3_Free_Connections() {
const int colnum=13;

@ -1,7 +1,10 @@
#include "proxysql.h"
#include "cpp.h"
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
#include "MySQL_PreparedStatement.h"
#include "MySQL_Protocol.h"

@ -5,7 +5,6 @@
#include "proxysql_utils.h"
#include "re2/re2.h"
#include "re2/regexp.h"
#include "SpookyV2.h"
#include "mysqld_error.h"
#include "set_parser.h"

@ -9,7 +9,6 @@
#include "proxysql.h"
#include "cpp.h"
#include "MySQL_Thread.h"
#include "SpookyV2.h"
#include <dirent.h>
#include <libgen.h>
#include "re2/re2.h"

@ -3,7 +3,10 @@
#include "MySQL_Session.h"
#include "MySQL_Data_Stream.h"
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
#include <sstream>

@ -42,7 +42,10 @@
#include <resolv.h>
#include <arpa/inet.h>
#include <pthread.h>
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
#include <fcntl.h>
#include <sys/utsname.h>
@ -3716,98 +3719,27 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) {
// handle special queries from Cluster
// for bug #1188 , ProxySQL Admin needs to know the exact query
if (!strncasecmp(CLUSTER_QUERY_MYSQL_SERVERS, query_no_space, strlen(CLUSTER_QUERY_MYSQL_SERVERS))) {
if (sess->session_type == PROXYSQL_SESSION_ADMIN) { // no stats
GloAdmin->mysql_servers_wrlock();
resultset = MyHGM->get_current_mysql_servers_inner();
GloAdmin->mysql_servers_wrunlock();
if (resultset == nullptr) {
resultset=MyHGM->dump_table_mysql_servers();
if (resultset) {
sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot);
delete resultset;
run_query=false;
goto __run_query;
}
} else {
sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot);
run_query=false;
goto __run_query;
}
}
}
if (!strncasecmp(CLUSTER_QUERY_MYSQL_REPLICATION_HOSTGROUPS, query_no_space, strlen(CLUSTER_QUERY_MYSQL_REPLICATION_HOSTGROUPS))) {
if (sess->session_type == PROXYSQL_SESSION_ADMIN) {
GloAdmin->mysql_servers_wrlock();
resultset = MyHGM->get_current_mysql_replication_hostgroups_inner();
GloAdmin->mysql_servers_wrunlock();
if (resultset == nullptr) {
resultset=MyHGM->dump_table_mysql_replication_hostgroups();
if (resultset) {
sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot);
delete resultset;
run_query=false;
goto __run_query;
}
} else {
sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot);
run_query=false;
goto __run_query;
}
}
}
if (!strncasecmp(CLUSTER_QUERY_MYSQL_GROUP_REPLICATION_HOSTGROUPS, query_no_space, strlen(CLUSTER_QUERY_MYSQL_GROUP_REPLICATION_HOSTGROUPS))) {
if (sess->session_type == PROXYSQL_SESSION_ADMIN) {
GloAdmin->mysql_servers_wrlock();
resultset = MyHGM->get_current_mysql_group_replication_hostgroups_inner();
GloAdmin->mysql_servers_wrunlock();
if (resultset == nullptr) {
resultset=MyHGM->dump_table_mysql_group_replication_hostgroups();
if (resultset) {
sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot);
delete resultset;
run_query=false;
goto __run_query;
}
} else {
sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot);
run_query=false;
goto __run_query;
}
}
}
if (!strncasecmp(CLUSTER_QUERY_MYSQL_GALERA, query_no_space, strlen(CLUSTER_QUERY_MYSQL_GALERA))) {
if (sess->session_type == PROXYSQL_SESSION_ADMIN) {
if (sess->session_type == PROXYSQL_SESSION_ADMIN) { // no stats
string tn = "";
if (!strncasecmp(CLUSTER_QUERY_MYSQL_SERVERS, query_no_space, strlen(CLUSTER_QUERY_MYSQL_SERVERS))) {
tn = "mysql_servers";
} else if (!strncasecmp(CLUSTER_QUERY_MYSQL_REPLICATION_HOSTGROUPS, query_no_space, strlen(CLUSTER_QUERY_MYSQL_REPLICATION_HOSTGROUPS))) {
tn = "mysql_replication_hostgroups";
} else if (!strncasecmp(CLUSTER_QUERY_MYSQL_GROUP_REPLICATION_HOSTGROUPS, query_no_space, strlen(CLUSTER_QUERY_MYSQL_GROUP_REPLICATION_HOSTGROUPS))) {
tn = "mysql_group_replication_hostgroups";
} else if (!strncasecmp(CLUSTER_QUERY_MYSQL_GALERA, query_no_space, strlen(CLUSTER_QUERY_MYSQL_GALERA))) {
tn = "mysql_galera_hostgroups";
} else if (!strncasecmp(CLUSTER_QUERY_MYSQL_AWS_AURORA, query_no_space, strlen(CLUSTER_QUERY_MYSQL_AWS_AURORA))) {
tn = "mysql_aws_aurora_hostgroups";
}
if (tn != "") {
GloAdmin->mysql_servers_wrlock();
resultset = MyHGM->get_current_mysql_galera_hostgroups();
resultset = MyHGM->get_current_mysql_table(tn);
GloAdmin->mysql_servers_wrunlock();
if (resultset == nullptr) {
resultset=MyHGM->dump_table_mysql_galera_hostgroups();
if (resultset) {
sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot);
delete resultset;
run_query=false;
goto __run_query;
}
} else {
sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot);
run_query=false;
goto __run_query;
}
}
}
if (!strncasecmp(CLUSTER_QUERY_MYSQL_AWS_AURORA, query_no_space, strlen(CLUSTER_QUERY_MYSQL_AWS_AURORA))) {
if (sess->session_type == PROXYSQL_SESSION_ADMIN) {
GloAdmin->mysql_servers_wrlock();
resultset = MyHGM->get_current_mysql_aws_aurora_hostgroups();
GloAdmin->mysql_servers_wrunlock();
if (resultset == nullptr) {
resultset=MyHGM->dump_table_mysql_aws_aurora_hostgroups();
resultset=MyHGM->dump_table_mysql(tn);
if (resultset) {
sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot);
delete resultset;
@ -3819,6 +3751,7 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) {
run_query=false;
goto __run_query;
}
}
}
@ -11676,7 +11609,7 @@ void ProxySQL_Admin::save_mysql_servers_runtime_to_database(bool _runtime) {
}
proxy_debug(PROXY_DEBUG_ADMIN, 4, "%s\n", query);
admindb->execute(query);
resultset=MyHGM->dump_table_mysql_servers();
resultset=MyHGM->dump_table_mysql("mysql_servers");
if (resultset) {
int rc;
sqlite3_stmt *statement1=NULL;
@ -11757,7 +11690,7 @@ void ProxySQL_Admin::save_mysql_servers_runtime_to_database(bool _runtime) {
}
proxy_debug(PROXY_DEBUG_ADMIN, 4, "%s\n", query);
admindb->execute(query);
resultset=MyHGM->dump_table_mysql_replication_hostgroups();
resultset=MyHGM->dump_table_mysql("mysql_replication_hostgroups");
if (resultset) {
for (std::vector<SQLite3_row *>::iterator it = resultset->rows.begin() ; it != resultset->rows.end(); ++it) {
SQLite3_row *r=*it;
@ -11795,7 +11728,7 @@ void ProxySQL_Admin::save_mysql_servers_runtime_to_database(bool _runtime) {
}
proxy_debug(PROXY_DEBUG_ADMIN, 4, "%s\n", query);
admindb->execute(query);
resultset=MyHGM->dump_table_mysql_group_replication_hostgroups();
resultset=MyHGM->dump_table_mysql("mysql__group_replication_hostgroups");
if (resultset) {
int rc;
sqlite3_stmt *statement=NULL;
@ -11839,7 +11772,7 @@ void ProxySQL_Admin::save_mysql_servers_runtime_to_database(bool _runtime) {
}
proxy_debug(PROXY_DEBUG_ADMIN, 4, "%s\n", query);
admindb->execute(query);
resultset=MyHGM->dump_table_mysql_galera_hostgroups();
resultset=MyHGM->dump_table_mysql("mysql_galera_hostgroups");
if (resultset) {
int rc;
sqlite3_stmt *statement=NULL;
@ -11884,7 +11817,7 @@ void ProxySQL_Admin::save_mysql_servers_runtime_to_database(bool _runtime) {
}
proxy_debug(PROXY_DEBUG_ADMIN, 4, "%s\n", query);
admindb->execute(query);
resultset=MyHGM->dump_table_mysql_aws_aurora_hostgroups();
resultset=MyHGM->dump_table_mysql("mysql_aws_aurora_hostgroups");
if (resultset) {
int rc;
sqlite3_stmt *statement=NULL;
@ -12004,7 +11937,7 @@ void ProxySQL_Admin::load_mysql_servers_to_runtime(
proxy_error("Error on %s : %s\n", query, error);
} else {
// Pass the resultset to MyHGM
MyHGM->save_incoming_replication_hostgroups(resultset_replication);
MyHGM->save_incoming_mysql_table(resultset_replication,"mysql_replication_hostgroups");
}
//if (resultset) delete resultset;
//resultset=NULL;
@ -12038,7 +11971,7 @@ void ProxySQL_Admin::load_mysql_servers_to_runtime(
proxy_error("Error on %s : %s\n", query, error);
} else {
// Pass the resultset to MyHGM
MyHGM->save_incoming_group_replication_hostgroups(resultset_group_replication);
MyHGM->save_incoming_mysql_table(resultset_group_replication,"mysql_group_replication_hostgroups");
}
// support for Galera, table mysql_galera_hostgroups
@ -12069,7 +12002,7 @@ void ProxySQL_Admin::load_mysql_servers_to_runtime(
proxy_error("Error on %s : %s\n", query, error);
} else {
// Pass the resultset to MyHGM
MyHGM->save_incoming_galera_hostgroups(resultset_galera);
MyHGM->save_incoming_mysql_table(resultset_galera, "mysql_galera_hostgroups");
}
// support for AWS Aurora, table mysql_aws_aurora_hostgroups
@ -12104,7 +12037,7 @@ void ProxySQL_Admin::load_mysql_servers_to_runtime(
proxy_error("Error on %s : %s\n", query, error);
} else {
// Pass the resultset to MyHGM
MyHGM->save_incoming_aws_aurora_hostgroups(resultset_aws_aurora);
MyHGM->save_incoming_mysql_table(resultset_aws_aurora,"mysql_aws_aurora_hostgroups");
}
// commit all the changes
MyHGM->commit(runtime_mysql_servers, checksum, epoch);

@ -3,7 +3,11 @@
#include "proxysql.h"
#include "proxysql_utils.h"
#include "cpp.h"
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
#include "prometheus_helpers.h"
#include "ProxySQL_Cluster.hpp"

@ -4,7 +4,11 @@
#include <string>
#include <sys/utsname.h>
#include <prometheus/registry.h>
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
#include <cxxabi.h>
#include <uuid/uuid.h>

@ -22,7 +22,10 @@
#include <resolv.h>
#include <arpa/inet.h>
#include <pthread.h>
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
#include <fcntl.h>
#include <sys/utsname.h>

@ -4,7 +4,7 @@
#include "cpp.h"
#include "query_cache.hpp"
#include "proxysql_atomic.h"
#include "SpookyV2.h"
//#include "SpookyV2.h"
#include "prometheus_helpers.h"
#include "MySQL_Protocol.h"

@ -10,7 +10,10 @@
#include "MySQL_Data_Stream.h"
#include "query_processor.h"
#ifndef SPOOKYV2
#include "SpookyV2.h"
#define SPOOKYV2
#endif
#include "pcrecpp.h"

@ -1,7 +1,7 @@
#include "MySQL_HostGroups_Manager.h"
#include "proxysql.h"
#include "cpp.h"
#include "SpookyV2.h"
//#include "SpookyV2.h"
#include <fcntl.h>
#include <sstream>

@ -1,6 +1,6 @@
#include "proxysql.h"
#include "cpp.h"
#include "SpookyV2.h"
//#include "SpookyV2.h"
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>

Loading…
Cancel
Save