diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index 3709781aae..81143b0be7 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -36,7 +36,7 @@ #define MYHGM_MYSQL_GALERA_HOSTGROUPS "CREATE TABLE mysql_galera_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , backup_writer_hostgroup INT CHECK (backup_writer_hostgroup>=0 AND backup_writer_hostgroup<>writer_hostgroup) NOT NULL , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND backup_writer_hostgroup<>reader_hostgroup AND reader_hostgroup>0) , offline_hostgroup INT NOT NULL CHECK (offline_hostgroup<>writer_hostgroup AND offline_hostgroup<>reader_hostgroup AND backup_writer_hostgroup<>offline_hostgroup AND offline_hostgroup>=0) , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , max_writers INT NOT NULL CHECK (max_writers >= 0) DEFAULT 1 , writer_is_also_reader INT CHECK (writer_is_also_reader IN (0,1,2)) NOT NULL DEFAULT 0 , max_transactions_behind INT CHECK (max_transactions_behind>=0) NOT NULL DEFAULT 0 , comment VARCHAR , UNIQUE (reader_hostgroup) , UNIQUE (offline_hostgroup) , UNIQUE (backup_writer_hostgroup))" -#define MYHGM_MYSQL_AWS_AURORA_HOSTGROUPS "CREATE TABLE mysql_aws_aurora_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>0) , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , aurora_port INT NOT NUlL DEFAULT 3306 , endpoint_address VARCHAR NOT NULL DEFAULT '' , max_lag_ms INT NOT NULL CHECK (max_lag_ms>= 10 AND max_lag_ms <= 600000) DEFAULT 600000 , check_interval_ms INT NOT NULL CHECK (check_interval_ms >= 100 AND check_interval_ms <= 600000) DEFAULT 1000 , check_timeout_ms INT NOT NULL CHECK (check_timeout_ms >= 80 AND check_timeout_ms <= 3000) DEFAULT 800 , writer_is_also_reader INT CHECK (writer_is_also_reader IN (0,1)) NOT NULL DEFAULT 0 , new_reader_weight INT CHECK (new_reader_weight >= 0 AND new_reader_weight <=10000000) NOT NULL DEFAULT 1 , comment VARCHAR , UNIQUE (reader_hostgroup))" +#define MYHGM_MYSQL_AWS_AURORA_HOSTGROUPS "CREATE TABLE mysql_aws_aurora_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>0) , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , aurora_port INT NOT NUlL DEFAULT 3306 , domain_name VARCHAR NOT NULL DEFAULT '' , max_lag_ms INT NOT NULL CHECK (max_lag_ms>= 10 AND max_lag_ms <= 600000) DEFAULT 600000 , check_interval_ms INT NOT NULL CHECK (check_interval_ms >= 100 AND check_interval_ms <= 600000) DEFAULT 1000 , check_timeout_ms INT NOT NULL CHECK (check_timeout_ms >= 80 AND check_timeout_ms <= 3000) DEFAULT 800 , writer_is_also_reader INT CHECK (writer_is_also_reader IN (0,1)) NOT NULL DEFAULT 0 , new_reader_weight INT CHECK (new_reader_weight >= 0 AND new_reader_weight <=10000000) NOT NULL DEFAULT 1 , comment VARCHAR , UNIQUE (reader_hostgroup))" typedef std::unordered_map umap_mysql_errors; @@ -443,7 +443,7 @@ class AWS_Aurora_Info { int new_reader_weight; // TODO // add intermediary status value, for example the last check time - char * endpoint_address; + char * domain_name; char * comment; bool active; bool __active; diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 2c31dda6f2..321ecd018c 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -2139,7 +2139,7 @@ SQLite3_result * MySQL_HostGroups_Manager::dump_table_mysql_aws_aurora_hostgroup int cols=0; int affected_rows=0; SQLite3_result *resultset=NULL; - char *query=(char *)"SELECT writer_hostgroup,reader_hostgroup,active,aurora_port,endpoint_address,max_lag_ms,check_interval_ms,check_timeout_ms,writer_is_also_reader,new_reader_weight,comment FROM mysql_aws_aurora_hostgroups"; + 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,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(); @@ -5139,7 +5139,7 @@ AWS_Aurora_Info::AWS_Aurora_Info(int w, int r, int _port, char *_end_addr, int m __active=true; //need_converge=true; aurora_port = _port; - endpoint_address = strdup(_end_addr); + domain_name = strdup(_end_addr); } AWS_Aurora_Info::~AWS_Aurora_Info() { @@ -5147,9 +5147,9 @@ AWS_Aurora_Info::~AWS_Aurora_Info() { free(comment); comment=NULL; } - if (endpoint_address) { - free(endpoint_address); - endpoint_address=NULL; + if (domain_name) { + free(domain_name); + domain_name=NULL; } } @@ -5188,21 +5188,21 @@ bool AWS_Aurora_Info::update(int r, int _port, char *_end_addr, int ml, int ci, aurora_port = _port; ret = true; } - if (endpoint_address) { + if (domain_name) { if (_end_addr) { - if (strcmp(endpoint_address,_end_addr)) { - free(endpoint_address); - endpoint_address = strdup(_end_addr); + if (strcmp(domain_name,_end_addr)) { + free(domain_name); + domain_name = strdup(_end_addr); ret = true; } } else { - free(endpoint_address); - endpoint_address=NULL; + free(domain_name); + domain_name=NULL; ret = true; } } else { if (_end_addr) { - endpoint_address=strdup(_end_addr); + domain_name=strdup(_end_addr); ret = true; } } @@ -5232,7 +5232,7 @@ void MySQL_HostGroups_Manager::generate_mysql_aws_aurora_hostgroups_table() { int rc; sqlite3_stmt *statement=NULL; //sqlite3 *mydb3=mydb->get_db(); - char *query=(char *)"INSERT INTO mysql_aws_aurora_hostgroups(writer_hostgroup,reader_hostgroup,active,aurora_port,endpoint_address,max_lag_ms,check_interval_ms,check_timeout_ms,writer_is_also_reader,new_reader_weight,comment) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)"; + char *query=(char *)"INSERT INTO mysql_aws_aurora_hostgroups(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,comment) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)"; //rc=sqlite3_prepare_v2(mydb3, query, -1, &statement, 0); rc = mydb->prepare_v2(query, &statement); assert(rc==SQLITE_OK); @@ -5337,7 +5337,7 @@ bool MySQL_HostGroups_Manager::aws_aurora_replication_lag_action(int _whid, int ret = false; } unsigned port = 3306; - char *endpoint_address = strdup((char *)""); + char *domain_name = strdup((char *)""); { pthread_mutex_lock(&AWS_Aurora_Info_mutex); std::map::iterator it2; @@ -5345,16 +5345,16 @@ bool MySQL_HostGroups_Manager::aws_aurora_replication_lag_action(int _whid, int AWS_Aurora_Info *info=NULL; if (it2!=AWS_Aurora_Info_Map.end()) { info=it2->second; - if (info->endpoint_address) { - free(endpoint_address); - endpoint_address = strdup(info->endpoint_address); + if (info->domain_name) { + free(domain_name); + domain_name = strdup(info->domain_name); } port = info->aurora_port; } pthread_mutex_unlock(&AWS_Aurora_Info_mutex); } - char *address = (char *)malloc(strlen(_server_id)+strlen(endpoint_address)+1); - sprintf(address,"%s%s",_server_id,endpoint_address); + char *address = (char *)malloc(strlen(_server_id)+strlen(domain_name)+1); + sprintf(address,"%s%s",_server_id,domain_name); GloAdmin->mysql_servers_wrlock(); wrlock(); int i,j; @@ -5419,7 +5419,7 @@ bool MySQL_HostGroups_Manager::aws_aurora_replication_lag_action(int _whid, int } } free(address); - free(endpoint_address); + free(domain_name); return ret; } @@ -5440,7 +5440,7 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid bool found_reader=false; int _writer_hostgroup = _whid; int aurora_port = 3306; - char *endpoint_address = strdup((char *)""); + char *domain_name = strdup((char *)""); int read_HG=-1; { pthread_mutex_lock(&AWS_Aurora_Info_mutex); @@ -5452,17 +5452,17 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid writer_is_also_reader=info->writer_is_also_reader; new_reader_weight = info->new_reader_weight; read_HG = info->reader_hostgroup; - if (info->endpoint_address) { - free(endpoint_address); - endpoint_address = strdup(info->endpoint_address); + if (info->domain_name) { + free(domain_name); + domain_name = strdup(info->domain_name); } aurora_port = info->aurora_port; } pthread_mutex_unlock(&AWS_Aurora_Info_mutex); } - query=(char *)malloc(strlen(q)+strlen(_server_id)+strlen(endpoint_address)+1024*1024); - sprintf(query, q, _server_id, endpoint_address, aurora_port); + query=(char *)malloc(strlen(q)+strlen(_server_id)+strlen(domain_name)+1024*1024); + sprintf(query, q, _server_id, domain_name, aurora_port); mydb->execute_statement(query, &error, &cols , &affected_rows , &resultset); if (error) { free(error); @@ -5552,21 +5552,21 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid sprintf(query,q,_writer_hostgroup); mydb->execute(query); q=(char *)"INSERT INTO mysql_servers_incoming SELECT hostgroup_id, hostname, port, gtid_port, weight, status, compression, max_connections, max_replication_lag, use_ssl, max_latency_ms, comment FROM mysql_servers WHERE hostgroup_id=%d AND hostname='%s%s' AND port=%d"; - sprintf(query, q, _writer_hostgroup, _server_id, endpoint_address, aurora_port); + sprintf(query, q, _writer_hostgroup, _server_id, domain_name, aurora_port); mydb->execute(query); q=(char *)"UPDATE OR IGNORE mysql_servers_incoming SET hostgroup_id=%d WHERE hostname='%s%s' AND port=%d AND hostgroup_id<>%d"; //query=(char *)malloc(strlen(q)+strlen(_hostname)+1024); // increased this buffer as it is used for other queries too - sprintf(query, q, _writer_hostgroup, _server_id, endpoint_address, aurora_port, _writer_hostgroup); + sprintf(query, q, _writer_hostgroup, _server_id, domain_name, aurora_port, _writer_hostgroup); mydb->execute(query); //free(query); q=(char *)"DELETE FROM mysql_servers_incoming WHERE hostname='%s%s' AND port=%d AND hostgroup_id<>%d"; //query=(char *)malloc(strlen(q)+strlen(_hostname)+64); - sprintf(query, q, _server_id, endpoint_address, aurora_port, _writer_hostgroup); + sprintf(query, q, _server_id, domain_name, aurora_port, _writer_hostgroup); mydb->execute(query); //free(query); q=(char *)"UPDATE mysql_servers_incoming SET status=0 WHERE hostname='%s%s' AND port=%d AND hostgroup_id=%d"; //query=(char *)malloc(strlen(q)+strlen(_hostname)+64); - sprintf(query, q, _server_id, endpoint_address, aurora_port, _writer_hostgroup); + sprintf(query, q, _server_id, domain_name, aurora_port, _writer_hostgroup); mydb->execute(query); // we need to move the old writer into the reader HG @@ -5580,10 +5580,10 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid //free(query); if (writer_is_also_reader && read_HG>=0) { q=(char *)"INSERT OR IGNORE INTO mysql_servers_incoming (hostgroup_id,hostname,port,gtid_port,status,weight,compression,max_connections,max_replication_lag,use_ssl,max_latency_ms,comment) SELECT %d,hostname,port,gtid_port,status,weight,compression,max_connections,max_replication_lag,use_ssl,max_latency_ms,comment FROM mysql_servers_incoming WHERE hostgroup_id=%d AND hostname='%s%s' AND port=%d"; - sprintf(query, q, read_HG, _writer_hostgroup, _server_id, endpoint_address, aurora_port); + sprintf(query, q, read_HG, _writer_hostgroup, _server_id, domain_name, aurora_port); mydb->execute(query); q = (char *)"UPDATE mysql_servers_incoming SET weight=%d WHERE hostgroup_id=%d AND hostname='%s%s' AND port=%d"; - sprintf(query, q, new_reader_weight, read_HG, _server_id, endpoint_address, aurora_port); + sprintf(query, q, new_reader_weight, read_HG, _server_id, domain_name, aurora_port); } uint64_t checksum_current = 0; uint64_t checksum_incoming = 0; @@ -5623,7 +5623,7 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid free(query); } if (checksum_incoming!=checksum_current) { - proxy_warning("AWS Aurora: setting host %s%s:%d as writer\n", _server_id, endpoint_address, aurora_port); + proxy_warning("AWS Aurora: setting host %s%s:%d as writer\n", _server_id, domain_name, aurora_port); commit(); wrlock(); /* @@ -5653,7 +5653,7 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid wrunlock(); } else { if (GloMTH->variables.hostgroup_manager_verbose > 1) { - proxy_warning("AWS Aurora: skipping setting node %s%s:%d from hostgroup %d as writer because won't change the list of ONLINE nodes in writer hostgroup\n", _server_id, endpoint_address, aurora_port, _writer_hostgroup); + proxy_warning("AWS Aurora: skipping setting node %s%s:%d from hostgroup %d as writer because won't change the list of ONLINE nodes in writer hostgroup\n", _server_id, domain_name, aurora_port, _writer_hostgroup); } } GloAdmin->mysql_servers_wrunlock(); @@ -5668,7 +5668,7 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid if (query) { free(query); } - free(endpoint_address); + free(domain_name); } void MySQL_HostGroups_Manager::update_aws_aurora_set_reader(int _whid, int _rhid, char *_server_id) { @@ -5680,7 +5680,7 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_reader(int _whid, int _rhid char *error=NULL; int _writer_hostgroup = _whid; int aurora_port = 3306; - char *endpoint_address = strdup((char *)""); + char *domain_name = strdup((char *)""); { pthread_mutex_lock(&AWS_Aurora_Info_mutex); std::map::iterator it2; @@ -5688,17 +5688,17 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_reader(int _whid, int _rhid AWS_Aurora_Info *info=NULL; if (it2!=AWS_Aurora_Info_Map.end()) { info=it2->second; - if (info->endpoint_address) { - free(endpoint_address); - endpoint_address = strdup(info->endpoint_address); + if (info->domain_name) { + free(domain_name); + domain_name = strdup(info->domain_name); } aurora_port = info->aurora_port; } pthread_mutex_unlock(&AWS_Aurora_Info_mutex); } q=(char *)"SELECT hostgroup_id FROM mysql_servers JOIN mysql_aws_aurora_hostgroups ON hostgroup_id=writer_hostgroup OR hostgroup_id=reader_hostgroup WHERE hostname='%s%s' AND port=%d AND status<>3"; - query=(char *)malloc(strlen(q)+strlen(_server_id)+strlen(endpoint_address)+32); - sprintf(query, q, _server_id, endpoint_address, aurora_port); + query=(char *)malloc(strlen(q)+strlen(_server_id)+strlen(domain_name)+32); + sprintf(query, q, _server_id, domain_name, aurora_port); mydb->execute_statement(query, &error, &cols , &affected_rows , &resultset); if (error) { free(error); @@ -5707,22 +5707,22 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_reader(int _whid, int _rhid free(query); if (resultset) { // we lock only if needed if (resultset->rows_count) { - proxy_warning("AWS Aurora: setting host %s%s:%d (part of cluster with writer_hostgroup=%d) in a reader, moving from writer_hostgroup %d to reader_hostgroup %d\n", _server_id, endpoint_address, aurora_port, _whid, _whid, _rhid); + proxy_warning("AWS Aurora: setting host %s%s:%d (part of cluster with writer_hostgroup=%d) in a reader, moving from writer_hostgroup %d to reader_hostgroup %d\n", _server_id, domain_name, aurora_port, _whid, _whid, _rhid); GloAdmin->mysql_servers_wrlock(); mydb->execute("DELETE FROM mysql_servers_incoming"); mydb->execute("INSERT INTO mysql_servers_incoming SELECT hostgroup_id, hostname, port, gtid_port, weight, status, compression, max_connections, max_replication_lag, use_ssl, max_latency_ms, comment FROM mysql_servers"); q=(char *)"UPDATE OR IGNORE mysql_servers_incoming SET hostgroup_id=%d WHERE hostname='%s%s' AND port=%d AND hostgroup_id<>%d"; - query=(char *)malloc(strlen(q)+strlen(_server_id)+strlen(endpoint_address)+512); - sprintf(query, q, _rhid, _server_id, endpoint_address, aurora_port, _rhid); + query=(char *)malloc(strlen(q)+strlen(_server_id)+strlen(domain_name)+512); + sprintf(query, q, _rhid, _server_id, domain_name, aurora_port, _rhid); mydb->execute(query); //free(query); q=(char *)"DELETE FROM mysql_servers_incoming WHERE hostname='%s%s' AND port=%d AND hostgroup_id<>%d"; //query=(char *)malloc(strlen(q)+strlen(_hostname)+64); - sprintf(query, q, _server_id, endpoint_address, aurora_port, _rhid); + sprintf(query, q, _server_id, domain_name, aurora_port, _rhid); mydb->execute(query); //free(query); q=(char *)"UPDATE mysql_servers_incoming SET status=0 WHERE hostname='%s%s' AND port=%d AND hostgroup_id=%d"; - sprintf(query, q, _server_id, endpoint_address, aurora_port, _rhid); + sprintf(query, q, _server_id, domain_name, aurora_port, _rhid); mydb->execute(query); //free(query); //converge_galera_config(_writer_hostgroup); @@ -5768,7 +5768,7 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_reader(int _whid, int _rhid delete resultset; resultset=NULL; } - free(endpoint_address); + free(domain_name); } diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 664b6758d1..655b55b646 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -359,11 +359,11 @@ static int http_handler(void *cls, struct MHD_Connection *connection, const char // AWS Aurora -#define ADMIN_SQLITE_TABLE_MYSQL_AWS_AURORA_HOSTGROUPS_V2_1_0a "CREATE TABLE mysql_aws_aurora_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>0) , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , aurora_port INT NOT NUlL DEFAULT 3306 , endpoint_address VARCHAR NOT NULL DEFAULT '' , max_lag_ms INT NOT NULL CHECK (max_lag_ms>= 10 AND max_lag_ms <= 600000) DEFAULT 600000 , check_interval_ms INT NOT NULL CHECK (check_interval_ms >= 100 AND check_interval_ms <= 600000) DEFAULT 1000 , check_timeout_ms INT NOT NULL CHECK (check_timeout_ms >= 80 AND check_timeout_ms <= 3000) DEFAULT 800 , writer_is_also_reader INT CHECK (writer_is_also_reader IN (0,1)) NOT NULL DEFAULT 0 , new_reader_weight INT CHECK (new_reader_weight >= 0 AND new_reader_weight <=10000000) NOT NULL DEFAULT 1 , comment VARCHAR , UNIQUE (reader_hostgroup))" +#define ADMIN_SQLITE_TABLE_MYSQL_AWS_AURORA_HOSTGROUPS_V2_1_0a "CREATE TABLE mysql_aws_aurora_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>0) , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , aurora_port INT NOT NUlL DEFAULT 3306 , domain_name VARCHAR NOT NULL CHECK (SUBSTR(domain_name,1,1) = '.') , max_lag_ms INT NOT NULL CHECK (max_lag_ms>= 10 AND max_lag_ms <= 600000) DEFAULT 600000 , check_interval_ms INT NOT NULL CHECK (check_interval_ms >= 100 AND check_interval_ms <= 600000) DEFAULT 1000 , check_timeout_ms INT NOT NULL CHECK (check_timeout_ms >= 80 AND check_timeout_ms <= 3000) DEFAULT 800 , writer_is_also_reader INT CHECK (writer_is_also_reader IN (0,1)) NOT NULL DEFAULT 0 , new_reader_weight INT CHECK (new_reader_weight >= 0 AND new_reader_weight <=10000000) NOT NULL DEFAULT 1 , comment VARCHAR , UNIQUE (reader_hostgroup))" #define ADMIN_SQLITE_TABLE_MYSQL_AWS_AURORA_HOSTGROUPS ADMIN_SQLITE_TABLE_MYSQL_AWS_AURORA_HOSTGROUPS_V2_1_0a -#define ADMIN_SQLITE_TABLE_RUNTIME_MYSQL_AWS_AURORA_HOSTGROUPS "CREATE TABLE runtime_mysql_aws_aurora_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>0) , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , aurora_port INT NOT NUlL DEFAULT 3306 , endpoint_address VARCHAR NOT NULL DEFAULT '' , max_lag_ms INT NOT NULL CHECK (max_lag_ms>= 10 AND max_lag_ms <= 600000) DEFAULT 600000 , check_interval_ms INT NOT NULL CHECK (check_interval_ms >= 100 AND check_interval_ms <= 600000) DEFAULT 1000 , check_timeout_ms INT NOT NULL CHECK (check_timeout_ms >= 80 AND check_timeout_ms <= 3000) DEFAULT 800 , writer_is_also_reader INT CHECK (writer_is_also_reader IN (0,1)) NOT NULL DEFAULT 0 , new_reader_weight INT CHECK (new_reader_weight >= 0 AND new_reader_weight <=10000000) NOT NULL DEFAULT 1 , comment VARCHAR , UNIQUE (reader_hostgroup))" +#define ADMIN_SQLITE_TABLE_RUNTIME_MYSQL_AWS_AURORA_HOSTGROUPS "CREATE TABLE runtime_mysql_aws_aurora_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>0) , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , aurora_port INT NOT NUlL DEFAULT 3306 , domain_name VARCHAR NOT NULL CHECK (SUBSTR(domain_name,1,1) = '.') , max_lag_ms INT NOT NULL CHECK (max_lag_ms>= 10 AND max_lag_ms <= 600000) DEFAULT 600000 , check_interval_ms INT NOT NULL CHECK (check_interval_ms >= 100 AND check_interval_ms <= 600000) DEFAULT 1000 , check_timeout_ms INT NOT NULL CHECK (check_timeout_ms >= 80 AND check_timeout_ms <= 3000) DEFAULT 800 , writer_is_also_reader INT CHECK (writer_is_also_reader IN (0,1)) NOT NULL DEFAULT 0 , new_reader_weight INT CHECK (new_reader_weight >= 0 AND new_reader_weight <=10000000) NOT NULL DEFAULT 1 , comment VARCHAR , UNIQUE (reader_hostgroup))" @@ -8320,9 +8320,9 @@ void ProxySQL_Admin::save_mysql_servers_runtime_to_database(bool _runtime) { //sqlite3 *mydb3=admindb->get_db(); char *query=NULL; if (_runtime) { - query=(char *)"INSERT INTO runtime_mysql_aws_aurora_hostgroups(writer_hostgroup,reader_hostgroup,active,aurora_port,endpoint_address,max_lag_ms,check_interval_ms,check_timeout_ms,writer_is_also_reader,new_reader_weight,comment) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)"; + query=(char *)"INSERT INTO runtime_mysql_aws_aurora_hostgroups(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,comment) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)"; } else { - query=(char *)"INSERT INTO mysql_aws_aurora_hostgroups(writer_hostgroup,reader_hostgroup,active,aurora_port,endpoint_address,max_lag_ms,check_interval_ms,check_timeout_ms,writer_is_also_reader,new_reader_weight,comment) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)"; + query=(char *)"INSERT INTO mysql_aws_aurora_hostgroups(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,comment) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)"; } //rc=sqlite3_prepare_v2(mydb3, query, -1, &statement, 0); rc = admindb->prepare_v2(query, &statement); @@ -9256,7 +9256,7 @@ int ProxySQL_Admin::Read_MySQL_Servers_from_configfile() { if (root.exists("mysql_aws_aurora_hostgroups")==true) { const Setting &mysql_aws_aurora_hostgroups = root["mysql_aws_aurora_hostgroups"]; int count = mysql_aws_aurora_hostgroups.getLength(); - char *q=(char *)"INSERT OR REPLACE INTO mysql_aws_aurora_hostgroups (writer_hostgroup, reader_hostgroup, active, aurora_port, endpoint_address, max_lag_ms, check_interval_ms, check_timeout_ms, writer_is_also_reader, new_reader_weight, comment) VALUES (%d, %d, %d, %d, '%s', %d, %d, %d, %d, %d, '%s')"; + char *q=(char *)"INSERT OR REPLACE INTO mysql_aws_aurora_hostgroups (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, comment) VALUES (%d, %d, %d, %d, '%s', %d, %d, %d, %d, %d, '%s')"; for (i=0; i< count; i++) { const Setting &line = mysql_aws_aurora_hostgroups[i]; int writer_hostgroup; @@ -9269,7 +9269,7 @@ int ProxySQL_Admin::Read_MySQL_Servers_from_configfile() { int writer_is_also_reader; int new_reader_weight; std::string comment=""; - std::string endpoint_address=""; + std::string domain_name=""; if (line.lookupValue("writer_hostgroup", writer_hostgroup)==false) continue; if (line.lookupValue("reader_hostgroup", reader_hostgroup)==false) continue; if (line.lookupValue("aurora_port", aurora_port)==false) aurora_port=3306; @@ -9279,10 +9279,10 @@ int ProxySQL_Admin::Read_MySQL_Servers_from_configfile() { if (line.lookupValue("writer_is_also_reader", writer_is_also_reader)==false) writer_is_also_reader=0; if (line.lookupValue("new_reader_weight", new_reader_weight)==false) new_reader_weight=0; line.lookupValue("comment", comment); - line.lookupValue("endpoint_address", comment); + line.lookupValue("domain_name", comment); char *o1=strdup(comment.c_str()); char *o=escape_string_single_quotes(o1, false); - char *p1=strdup(endpoint_address.c_str()); + char *p1=strdup(domain_name.c_str()); char *p=escape_string_single_quotes(p1, false); char *query=(char *)malloc(strlen(q)+strlen(o)+strlen(p)+256); // 128 vs sizeof(int)*8 sprintf(query,q, writer_hostgroup, reader_hostgroup, active, aurora_port, p, max_lag_ms, check_interval_ms, check_timeout_ms, writer_is_also_reader, new_reader_weight, o); @@ -10311,7 +10311,7 @@ void ProxySQL_Admin::enable_aurora_testing() { } } sqlite3_finalize(statement); - admindb->execute("INSERT INTO mysql_aws_aurora_hostgroups (writer_hostgroup, reader_hostgroup, active, endpoint_address, max_lag_ms, check_interval_ms, check_timeout_ms, writer_is_also_reader, new_reader_weight, comment) VALUES (1271, 1272, 1, '.aws-test.com', 25, 120, 90, 1, 1, 'Automated Aurora Testing Cluster 1')"); + admindb->execute("INSERT INTO mysql_aws_aurora_hostgroups (writer_hostgroup, reader_hostgroup, active, domain_name, max_lag_ms, check_interval_ms, check_timeout_ms, writer_is_also_reader, new_reader_weight, comment) VALUES (1271, 1272, 1, '.aws-test.com', 25, 120, 90, 1, 1, 'Automated Aurora Testing Cluster 1')"); admindb->execute("INSERT INTO mysql_aws_aurora_hostgroups (writer_hostgroup, reader_hostgroup, active, max_lag_ms, check_interval_ms, check_timeout_ms, writer_is_also_reader, new_reader_weight, comment) VALUES (1273, 1274, 1, 25, 120, 90, 0, 1, 'Automated Aurora Testing Cluster 2')"); admindb->execute("INSERT INTO mysql_aws_aurora_hostgroups (writer_hostgroup, reader_hostgroup, active, max_lag_ms, check_interval_ms, check_timeout_ms, writer_is_also_reader, new_reader_weight, comment) VALUES (1275, 1276, 1, 25, 120, 90, 0, 2, 'Automated Aurora Testing Cluster 3')"); admindb->execute("UPDATE mysql_aws_aurora_hostgroups SET active=1");