diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index 9014767fd..bfd6f329e 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -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 diff --git a/lib/ClickHouse_Authentication.cpp b/lib/ClickHouse_Authentication.cpp index 7bf86dcbb..1ba006207 100644 --- a/lib/ClickHouse_Authentication.cpp +++ b/lib/ClickHouse_Authentication.cpp @@ -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 diff --git a/lib/ClickHouse_Server.cpp b/lib/ClickHouse_Server.cpp index b3b61061c..4fc3d46e3 100644 --- a/lib/ClickHouse_Server.cpp +++ b/lib/ClickHouse_Server.cpp @@ -23,7 +23,10 @@ #include #include #include +#ifndef SPOOKYV2 #include "SpookyV2.h" +#define SPOOKYV2 +#endif #include #include diff --git a/lib/MySQL_Authentication.cpp b/lib/MySQL_Authentication.cpp index 1a463082c..e06bc8a00 100644 --- a/lib/MySQL_Authentication.cpp +++ b/lib/MySQL_Authentication.cpp @@ -5,7 +5,10 @@ #include "MySQL_Authentication.hpp" +#ifndef SPOOKYV2 #include "SpookyV2.h" +#define SPOOKYV2 +#endif MySQL_Authentication::MySQL_Authentication() { #ifdef DEBUG diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index df88ca14f..c194259f5 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -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; diff --git a/lib/MySQL_PreparedStatement.cpp b/lib/MySQL_PreparedStatement.cpp index 80ed1766b..a7bc04b7a 100644 --- a/lib/MySQL_PreparedStatement.cpp +++ b/lib/MySQL_PreparedStatement.cpp @@ -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" diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 4a9a7a24a..c511f68a5 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -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" diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 6c0771812..ba6ed9a07 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -9,7 +9,6 @@ #include "proxysql.h" #include "cpp.h" #include "MySQL_Thread.h" -#include "SpookyV2.h" #include #include #include "re2/re2.h" diff --git a/lib/MySQL_Variables.cpp b/lib/MySQL_Variables.cpp index f0c4111c7..e60c4b3ab 100644 --- a/lib/MySQL_Variables.cpp +++ b/lib/MySQL_Variables.cpp @@ -3,7 +3,10 @@ #include "MySQL_Session.h" #include "MySQL_Data_Stream.h" +#ifndef SPOOKYV2 #include "SpookyV2.h" +#define SPOOKYV2 +#endif #include diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 54f8644a9..2a7f54deb 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -42,7 +42,10 @@ #include #include #include +#ifndef SPOOKYV2 #include "SpookyV2.h" +#define SPOOKYV2 +#endif #include #include @@ -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::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); diff --git a/lib/ProxySQL_Cluster.cpp b/lib/ProxySQL_Cluster.cpp index 6e6d29877..1e6260e96 100644 --- a/lib/ProxySQL_Cluster.cpp +++ b/lib/ProxySQL_Cluster.cpp @@ -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" diff --git a/lib/ProxySQL_GloVars.cpp b/lib/ProxySQL_GloVars.cpp index 741f751dd..1df01f531 100644 --- a/lib/ProxySQL_GloVars.cpp +++ b/lib/ProxySQL_GloVars.cpp @@ -4,7 +4,11 @@ #include #include #include +#ifndef SPOOKYV2 #include "SpookyV2.h" +#define SPOOKYV2 +#endif + #include #include diff --git a/lib/ProxySQL_HTTP_Server.cpp b/lib/ProxySQL_HTTP_Server.cpp index c116a12c9..e82b18a24 100644 --- a/lib/ProxySQL_HTTP_Server.cpp +++ b/lib/ProxySQL_HTTP_Server.cpp @@ -22,7 +22,10 @@ #include #include #include +#ifndef SPOOKYV2 #include "SpookyV2.h" +#define SPOOKYV2 +#endif #include #include diff --git a/lib/Query_Cache.cpp b/lib/Query_Cache.cpp index a6af25a47..59315e2d6 100644 --- a/lib/Query_Cache.cpp +++ b/lib/Query_Cache.cpp @@ -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" diff --git a/lib/Query_Processor.cpp b/lib/Query_Processor.cpp index 1382cb4cf..debba9d22 100644 --- a/lib/Query_Processor.cpp +++ b/lib/Query_Processor.cpp @@ -10,7 +10,10 @@ #include "MySQL_Data_Stream.h" #include "query_processor.h" +#ifndef SPOOKYV2 #include "SpookyV2.h" +#define SPOOKYV2 +#endif #include "pcrecpp.h" diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index acc06ba98..7b9944dc0 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -1,7 +1,7 @@ #include "MySQL_HostGroups_Manager.h" #include "proxysql.h" #include "cpp.h" -#include "SpookyV2.h" +//#include "SpookyV2.h" #include #include diff --git a/lib/sqlite3db.cpp b/lib/sqlite3db.cpp index e839ef211..4b715aac8 100644 --- a/lib/sqlite3db.cpp +++ b/lib/sqlite3db.cpp @@ -1,6 +1,6 @@ #include "proxysql.h" #include "cpp.h" -#include "SpookyV2.h" +//#include "SpookyV2.h" #include #include #include