Second commit to support Aurora

It adds port and endpoint_address in mysql_aws_aurora_hostgroups
pull/2044/head
René Cannaò 7 years ago
parent 0c232bf04b
commit b36f5d785a

@ -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 , 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 , 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))"
typedef std::unordered_map<std::uint64_t, void *> umap_mysql_errors;
@ -435,6 +435,7 @@ class AWS_Aurora_Info {
public:
int writer_hostgroup;
int reader_hostgroup;
int aurora_port;
int max_lag_ms;
int check_interval_ms;
int check_timeout_ms;
@ -442,11 +443,12 @@ class AWS_Aurora_Info {
int new_reader_weight;
// TODO
// add intermediary status value, for example the last check time
char * endpoint_address;
char * comment;
bool active;
bool __active;
AWS_Aurora_Info(int w, int r, int ml, int ci, int ct, bool _a, int wiar, int nrw, char *c);
bool update(int r, int ml, int ci, int ct, bool _a, int wiar, int nrw, char *c);
AWS_Aurora_Info(int w, int r, int _port, char *_end_addr, int ml, int ci, int ct, bool _a, int wiar, int nrw, char *c);
bool update(int r, int _port, char *_end_addr, int ml, int ci, int ct, bool _a, int wiar, int nrw, char *c);
~AWS_Aurora_Info();
};
@ -593,9 +595,12 @@ class MySQL_HostGroups_Manager {
// FIXME : add action functions for AWS Aurora
//void aws_aurora_replication_lag_action(int _whid, int _rhid, char *address, unsigned int port, float current_replication_lag, bool enable, bool verbose=true);
bool aws_aurora_replication_lag_action(int _whid, int _rhid, char *address, unsigned int port, unsigned int current_replication_lag_us, bool enable, bool is_writer, bool verbose=true);
void update_aws_aurora_set_writer(int _whid, int _rhid, char *address, unsigned int port, bool verbose=true);
void update_aws_aurora_set_reader(int _whid, int _rhid, char *_hostname, int _port);
//bool aws_aurora_replication_lag_action(int _whid, int _rhid, char *address, unsigned int port, unsigned int current_replication_lag_us, bool enable, bool is_writer, bool verbose=true);
//void update_aws_aurora_set_writer(int _whid, int _rhid, char *address, unsigned int port, bool verbose=true);
//void update_aws_aurora_set_reader(int _whid, int _rhid, char *_hostname, int _port);
bool aws_aurora_replication_lag_action(int _whid, int _rhid, char *server_id, unsigned int current_replication_lag_us, bool enable, bool is_writer, bool verbose=true);
void update_aws_aurora_set_writer(int _whid, int _rhid, char *server_id, bool verbose=true);
void update_aws_aurora_set_reader(int _whid, int _rhid, char *server_id);
SQLite3_result * get_stats_mysql_gtid_executed();
void generate_mysql_gtid_executed_tables();

@ -2098,7 +2098,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,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,endpoint_address,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();
@ -4733,7 +4733,7 @@ SQLite3_result * MySQL_HostGroups_Manager::get_mysql_errors(bool reset) {
return result;
}
AWS_Aurora_Info::AWS_Aurora_Info(int w, int r, int ml, int ci, int ct, bool _a, int wiar, int nrw, char *c) {
AWS_Aurora_Info::AWS_Aurora_Info(int w, int r, int _port, char *_end_addr, int ml, int ci, int ct, bool _a, int wiar, int nrw, char *c) {
comment=NULL;
if (c) {
comment=strdup(c);
@ -4748,6 +4748,8 @@ AWS_Aurora_Info::AWS_Aurora_Info(int w, int r, int ml, int ci, int ct, bool _a,
active=_a;
__active=true;
//need_converge=true;
aurora_port = _port;
endpoint_address = strdup(_end_addr);
}
AWS_Aurora_Info::~AWS_Aurora_Info() {
@ -4755,9 +4757,13 @@ AWS_Aurora_Info::~AWS_Aurora_Info() {
free(comment);
comment=NULL;
}
if (endpoint_address) {
free(endpoint_address);
endpoint_address=NULL;
}
}
bool AWS_Aurora_Info::update(int r, int ml, int ci, int ct, bool _a, int wiar, int nrw, char *c) {
bool AWS_Aurora_Info::update(int r, int _port, char *_end_addr, int ml, int ci, int ct, bool _a, int wiar, int nrw, char *c) {
bool ret=false;
__active=true;
if (reader_hostgroup!=r) {
@ -4788,6 +4794,28 @@ bool AWS_Aurora_Info::update(int r, int ml, int ci, int ct, bool _a, int wiar, i
active=_a;
ret=true;
}
if (aurora_port != _port) {
aurora_port = _port;
ret = true;
}
if (endpoint_address) {
if (_end_addr) {
if (strcmp(endpoint_address,_end_addr)) {
free(endpoint_address);
endpoint_address = strdup(_end_addr);
ret = true;
}
} else {
free(endpoint_address);
endpoint_address=NULL;
ret = true;
}
} else {
if (_end_addr) {
endpoint_address=strdup(_end_addr);
ret = true;
}
}
// for comment we don't change return value
if (comment) {
if (c) {
@ -4814,7 +4842,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,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)";
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)";
rc=sqlite3_prepare_v2(mydb3, query, -1, &statement, 0);
assert(rc==SQLITE_OK);
proxy_info("New mysql_aws_aurora_hostgroups table\n");
@ -4829,21 +4857,24 @@ void MySQL_HostGroups_Manager::generate_mysql_aws_aurora_hostgroups_table() {
int writer_hostgroup=atoi(r->fields[0]);
int reader_hostgroup=atoi(r->fields[1]);
int active=atoi(r->fields[2]);
int max_lag_ms = atoi(r->fields[3]);
int check_interval_ms = atoi(r->fields[4]);
int check_timeout_ms = atoi(r->fields[5]);
int writer_is_also_reader = atoi(r->fields[6]);
int new_reader_weight = atoi(r->fields[7]);
proxy_info("Loading AWS Aurora info for (%d,%d,%s,%d,%d,%d,\"%s\")\n", writer_hostgroup,reader_hostgroup,(active ? "on" : "off"),max_lag_ms,check_interval_ms,check_timeout_ms,r->fields[6]);
int aurora_port = atoi(r->fields[3]);
int max_lag_ms = atoi(r->fields[5]);
int check_interval_ms = atoi(r->fields[6]);
int check_timeout_ms = atoi(r->fields[7]);
int writer_is_also_reader = atoi(r->fields[8]);
int new_reader_weight = atoi(r->fields[9]);
proxy_info("Loading AWS Aurora info for (%d,%d,%s,%d,\"%s\",%d,%d,%d,\"%s\")\n", writer_hostgroup,reader_hostgroup,(active ? "on" : "off"),aurora_port,r->fields[4],max_lag_ms,check_interval_ms,check_timeout_ms,r->fields[10]);
rc=sqlite3_bind_int64(statement, 1, writer_hostgroup); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 2, reader_hostgroup); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 3, active); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 4, max_lag_ms); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 5, check_interval_ms); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 6, check_timeout_ms); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 7, writer_is_also_reader); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 8, new_reader_weight); assert(rc==SQLITE_OK);
rc=sqlite3_bind_text(statement, 9, r->fields[8], -1, SQLITE_TRANSIENT); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 4, aurora_port); assert(rc==SQLITE_OK);
rc=sqlite3_bind_text(statement, 5, r->fields[4], -1, SQLITE_TRANSIENT); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 6, max_lag_ms); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 7, check_interval_ms); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 8, check_timeout_ms); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 9, writer_is_also_reader); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 10, new_reader_weight); assert(rc==SQLITE_OK);
rc=sqlite3_bind_text(statement, 11, r->fields[10], -1, SQLITE_TRANSIENT); assert(rc==SQLITE_OK);
SAFE_SQLITE3_STEP2(statement);
rc=sqlite3_clear_bindings(statement); assert(rc==SQLITE_OK);
@ -4854,12 +4885,12 @@ void MySQL_HostGroups_Manager::generate_mysql_aws_aurora_hostgroups_table() {
if (it2!=AWS_Aurora_Info_Map.end()) {
info=it2->second;
bool changed=false;
changed=info->update(reader_hostgroup, max_lag_ms, check_interval_ms, check_timeout_ms, (bool)active, writer_is_also_reader, new_reader_weight, r->fields[8]);
changed=info->update(reader_hostgroup, aurora_port, r->fields[4], max_lag_ms, check_interval_ms, check_timeout_ms, (bool)active, writer_is_also_reader, new_reader_weight, r->fields[10]);
if (changed) {
//info->need_converge=true;
}
} else {
info=new AWS_Aurora_Info(writer_hostgroup, reader_hostgroup, max_lag_ms, check_interval_ms, check_timeout_ms, (bool)active, writer_is_also_reader, new_reader_weight, r->fields[8]);
info=new AWS_Aurora_Info(writer_hostgroup, reader_hostgroup, aurora_port, r->fields[4], max_lag_ms, check_interval_ms, check_timeout_ms, (bool)active, writer_is_also_reader, new_reader_weight, r->fields[10]);
//info->need_converge=true;
AWS_Aurora_Info_Map.insert(AWS_Aurora_Info_Map.begin(), std::pair<int, AWS_Aurora_Info *>(writer_hostgroup,info));
}
@ -4907,13 +4938,32 @@ void MySQL_HostGroups_Manager::generate_mysql_aws_aurora_hostgroups_table() {
//void MySQL_HostGroups_Manager::aws_aurora_replication_lag_action(int _whid, int _rhid, char *address, unsigned int port, float current_replication_lag, bool enable, bool verbose) {
// this function returns false is the server is in the wrong HG
bool MySQL_HostGroups_Manager::aws_aurora_replication_lag_action(int _whid, int _rhid, char *address, unsigned int port, unsigned int current_replication_lag_us, bool enable, bool is_writer, bool verbose) {
bool MySQL_HostGroups_Manager::aws_aurora_replication_lag_action(int _whid, int _rhid, char *_server_id, unsigned int current_replication_lag_us, bool enable, bool is_writer, bool verbose) {
bool ret = false; // return false by default
bool reader_found_in_whg = false;
if (is_writer) {
// if the server is a writer, we will set ret back to true once found
ret = false;
}
unsigned port = 3306;
char *endpoint_address = strdup((char *)"");
{
pthread_mutex_lock(&AWS_Aurora_Info_mutex);
std::map<int , AWS_Aurora_Info *>::iterator it2;
it2 = AWS_Aurora_Info_Map.find(_whid);
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);
}
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);
GloAdmin->mysql_servers_wrlock();
wrlock();
int i,j;
@ -4977,11 +5027,13 @@ bool MySQL_HostGroups_Manager::aws_aurora_replication_lag_action(int _whid, int
ret = false;
}
}
free(address);
free(endpoint_address);
return ret;
}
// FIXME: complete this!!
void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid, char *_hostname, unsigned int _port, bool verbose) {
void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid, char *_server_id, bool verbose) {
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
@ -4989,25 +5041,46 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid
char *q=NULL;
char *error=NULL;
//q=(char *)"SELECT hostgroup_id FROM mysql_servers JOIN mysql_galera_hostgroups ON hostgroup_id=writer_hostgroup OR hostgroup_id=reader_hostgroup OR hostgroup_id=backup_writer_hostgroup OR hostgroup_id=offline_hostgroup WHERE hostname='%s' AND port=%d AND status<>3";
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' AND port=%d AND status<>3";
query=(char *)malloc(strlen(q)+strlen(_hostname)+1024*1024);
sprintf(query,q,_hostname,_port);
mydb->execute_statement(query, &error, &cols , &affected_rows , &resultset);
if (error) {
free(error);
error=NULL;
}
//free(query);
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";
int writer_is_also_reader=0;
int new_reader_weight = 0;
bool found_writer=false;
bool found_reader=false;
int _writer_hostgroup = _whid;
int aurora_port = 3306;
char *endpoint_address = strdup((char *)"");
int read_HG=-1;
//bool need_converge=false;
//bool need_converge=true;
{
pthread_mutex_lock(&AWS_Aurora_Info_mutex);
std::map<int , AWS_Aurora_Info *>::iterator it2;
it2 = AWS_Aurora_Info_Map.find(_writer_hostgroup);
AWS_Aurora_Info *info=NULL;
if (it2!=AWS_Aurora_Info_Map.end()) {
info=it2->second;
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);
}
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);
mydb->execute_statement(query, &error, &cols , &affected_rows , &resultset);
if (error) {
free(error);
error=NULL;
}
//free(query);
if (resultset) {
/*
// let's get info about this cluster
pthread_mutex_lock(&AWS_Aurora_Info_mutex);
std::map<int , AWS_Aurora_Info *>::iterator it2;
@ -5023,7 +5096,7 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid
//max_writers = info->max_writers;
}
pthread_mutex_unlock(&AWS_Aurora_Info_mutex);
*/
if (resultset->rows_count) {
for (std::vector<SQLite3_row *>::iterator it = resultset->rows.begin() ; it != resultset->rows.end(); ++it) {
SQLite3_row *r=*it;
@ -5087,22 +5160,22 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid
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";
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' AND port=%d";
sprintf(query,q,_writer_hostgroup,_hostname,_port);
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);
mydb->execute(query);
q=(char *)"UPDATE OR IGNORE mysql_servers_incoming SET hostgroup_id=%d WHERE hostname='%s' AND port=%d AND hostgroup_id<>%d";
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,_hostname,_port,_writer_hostgroup);
sprintf(query, q, _writer_hostgroup, _server_id, endpoint_address, aurora_port, _writer_hostgroup);
mydb->execute(query);
//free(query);
q=(char *)"DELETE FROM mysql_servers_incoming WHERE hostname='%s' AND port=%d AND hostgroup_id<>%d";
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,_hostname,_port,_writer_hostgroup);
sprintf(query, q, _server_id, endpoint_address, aurora_port, _writer_hostgroup);
mydb->execute(query);
//free(query);
q=(char *)"UPDATE mysql_servers_incoming SET status=0 WHERE hostname='%s' AND port=%d AND hostgroup_id=%d";
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,_hostname,_port,_writer_hostgroup);
sprintf(query, q, _server_id, endpoint_address, aurora_port, _writer_hostgroup);
mydb->execute(query);
// we need to move the old writer into the reader HG
@ -5115,13 +5188,12 @@ 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' AND port=%d";
sprintf(query,q,read_HG,_writer_hostgroup,_hostname,_port);
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);
mydb->execute(query);
q = (char *)"UPDATE mysql_servers_incoming SET weight=%d WHERE hostgroup_id=%d AND hostname='%s' AND port=%d";
sprintf(query, q, new_reader_weight, read_HG, _hostname, _port);
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);
}
//converge_galera_config(_writer_hostgroup);
uint64_t checksum_current = 0;
uint64_t checksum_incoming = 0;
{
@ -5160,7 +5232,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:%d as writer\n", _hostname, _port);
proxy_warning("AWS Aurora: setting host %s%s:%d as writer\n", _server_id, endpoint_address, aurora_port);
commit();
wrlock();
/*
@ -5190,7 +5262,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:%d from hostgroup %d as writer because won't change the list of ONLINE nodes in writer hostgroup\n", _hostname, _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, endpoint_address, aurora_port, _writer_hostgroup);
}
}
GloAdmin->mysql_servers_wrunlock();
@ -5205,9 +5277,10 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid
if (query) {
free(query);
}
free(endpoint_address);
}
void MySQL_HostGroups_Manager::update_aws_aurora_set_reader(int _whid, int _rhid, char *_hostname, int _port) {
void MySQL_HostGroups_Manager::update_aws_aurora_set_reader(int _whid, int _rhid, char *_server_id) {
int cols=0;
int affected_rows=0;
SQLite3_result *resultset=NULL;
@ -5215,9 +5288,26 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_reader(int _whid, int _rhid
char *q=NULL;
char *error=NULL;
int _writer_hostgroup = _whid;
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' AND port=%d AND status<>3";
query=(char *)malloc(strlen(q)+strlen(_hostname)+32);
sprintf(query,q,_hostname,_port);
int aurora_port = 3306;
char *endpoint_address = strdup((char *)"");
{
pthread_mutex_lock(&AWS_Aurora_Info_mutex);
std::map<int , AWS_Aurora_Info *>::iterator it2;
it2 = AWS_Aurora_Info_Map.find(_writer_hostgroup);
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);
}
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);
mydb->execute_statement(query, &error, &cols , &affected_rows , &resultset);
if (error) {
free(error);
@ -5226,22 +5316,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:%d (part of cluster with writer_hostgroup=%d) in a reader, moving from writer_hostgroup %d to reader_hostgroup %d\n", _hostname, _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, endpoint_address, 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' AND port=%d AND hostgroup_id<>%d";
query=(char *)malloc(strlen(q)+strlen(_hostname)+512);
sprintf(query,q,_rhid,_hostname,_port,_rhid);
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);
mydb->execute(query);
//free(query);
q=(char *)"DELETE FROM mysql_servers_incoming WHERE hostname='%s' AND port=%d AND hostgroup_id<>%d";
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,_hostname,_port,_rhid);
sprintf(query, q, _server_id, endpoint_address, aurora_port, _rhid);
mydb->execute(query);
//free(query);
q=(char *)"UPDATE mysql_servers_incoming SET status=0 WHERE hostname='%s' AND port=%d AND hostgroup_id=%d";
sprintf(query,q,_hostname,_port,_rhid);
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);
mydb->execute(query);
//free(query);
//converge_galera_config(_writer_hostgroup);
@ -5287,6 +5377,7 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_reader(int _whid, int _rhid
delete resultset;
resultset=NULL;
}
free(endpoint_address);
}

@ -3477,8 +3477,12 @@ __exit_monitor_aws_aurora_HG_thread:
s=(char *)malloc(l+16);
}
sprintf(s,"%s:%d",mmsd->hostname,mmsd->port);
AWS_Aurora_status_entry *ase = new AWS_Aurora_status_entry(mmsd->t1, mmsd->t2-mmsd->t1, mmsd->mysql_error_msg);
AWS_Aurora_status_entry *ase_l = new AWS_Aurora_status_entry(mmsd->t1, mmsd->t2-mmsd->t1, mmsd->mysql_error_msg);
unsigned long long time_now=realtime_time();
time_now=time_now-(mmsd->t2 - start_time);
//AWS_Aurora_status_entry *ase = new AWS_Aurora_status_entry(mmsd->t1, mmsd->t2-mmsd->t1, mmsd->mysql_error_msg);
//AWS_Aurora_status_entry *ase_l = new AWS_Aurora_status_entry(mmsd->t1, mmsd->t2-mmsd->t1, mmsd->mysql_error_msg);
AWS_Aurora_status_entry *ase = new AWS_Aurora_status_entry(time_now, mmsd->t2-mmsd->t1, mmsd->mysql_error_msg);
AWS_Aurora_status_entry *ase_l = new AWS_Aurora_status_entry(time_now, mmsd->t2-mmsd->t1, mmsd->mysql_error_msg);
if (mmsd->interr == 0 && mmsd->result) {
int num_fields=0;
int num_rows=0;
@ -3500,8 +3504,6 @@ __exit_monitor_aws_aurora_HG_thread:
//__end_process_aws_aurora_result:
if (mmsd->mysql_error_msg) {
}
unsigned long long time_now=realtime_time();
time_now=time_now-(mmsd->t2 - start_time);
pthread_mutex_lock(&GloMyMon->aws_aurora_mutex);
//auto it =
// TODO : complete this
@ -4064,15 +4066,15 @@ void MySQL_Monitor::evaluate_aws_aurora_results(unsigned int wHG, unsigned int r
#ifdef TEST_AURORA
action_yes++;
(enable ? enabling++ : disabling++);
rla_rc = MyHGM->aws_aurora_replication_lag_action(wHG, rHG, hse->server_id, 3306, hse->replica_lag_ms, enable, is_writer, verbose);
rla_rc = MyHGM->aws_aurora_replication_lag_action(wHG, rHG, hse->server_id, hse->replica_lag_ms, enable, is_writer, verbose);
#else
rla_rc = MyHGM->aws_aurora_replication_lag_action(wHG, rHG, hse->server_id, 3306, hse->replica_lag_ms, enable, is_writer);
rla_rc = MyHGM->aws_aurora_replication_lag_action(wHG, rHG, hse->server_id, hse->replica_lag_ms, enable, is_writer);
#endif // TEST_AURORA
#ifdef TEST_AURORA
} else {
action_no++;
#endif // TEST_AURORA
rla_rc = MyHGM->aws_aurora_replication_lag_action(wHG, rHG, hse->server_id, 3306, hse->replica_lag_ms, enable, is_writer);
rla_rc = MyHGM->aws_aurora_replication_lag_action(wHG, rHG, hse->server_id, hse->replica_lag_ms, enable, is_writer);
}
//if (is_writer == true && rla_rc == false) {
if (rla_rc == false) {
@ -4081,7 +4083,7 @@ void MySQL_Monitor::evaluate_aws_aurora_results(unsigned int wHG, unsigned int r
#ifdef TEST_AURORA
proxy_info("Calling update_aws_aurora_set_writer for %s\n", hse->server_id);
#endif // TEST_AURORA
MyHGM->update_aws_aurora_set_writer(wHG, rHG, hse->server_id, 3306);
MyHGM->update_aws_aurora_set_writer(wHG, rHG, hse->server_id);
time_t __timer;
char lut[30];
struct tm __tm_info;
@ -4097,7 +4099,7 @@ void MySQL_Monitor::evaluate_aws_aurora_results(unsigned int wHG, unsigned int r
#ifdef TEST_AURORA
proxy_info("Calling update_aws_aurora_set_reader for %s\n", hse->server_id);
#endif // TEST_AURORA
MyHGM->update_aws_aurora_set_reader(wHG, rHG, hse->server_id, 3306);
MyHGM->update_aws_aurora_set_reader(wHG, rHG, hse->server_id);
}
}
}

@ -343,11 +343,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 , 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 , 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 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 , 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 , 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))"
@ -7770,9 +7770,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,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)";
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)";
} else {
query=(char *)"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 (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)";
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)";
}
rc=sqlite3_prepare_v2(mydb3, query, -1, &statement, 0);
assert(rc==SQLITE_OK);
@ -7783,11 +7783,13 @@ void ProxySQL_Admin::save_mysql_servers_runtime_to_database(bool _runtime) {
rc=sqlite3_bind_int64(statement, 2, atoi(r->fields[1])); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 3, atoi(r->fields[2])); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 4, atoi(r->fields[3])); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 5, atoi(r->fields[4])); assert(rc==SQLITE_OK);
rc=sqlite3_bind_text(statement, 5, r->fields[4], -1, SQLITE_TRANSIENT); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 6, atoi(r->fields[5])); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 7, atoi(r->fields[6])); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 8, atoi(r->fields[7])); assert(rc==SQLITE_OK);
rc=sqlite3_bind_text(statement, 9, r->fields[8], -1, SQLITE_TRANSIENT); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 9, atoi(r->fields[8])); assert(rc==SQLITE_OK);
rc=sqlite3_bind_int64(statement, 10, atoi(r->fields[9])); assert(rc==SQLITE_OK);
rc=sqlite3_bind_text(statement, 11, r->fields[10], -1, SQLITE_TRANSIENT); assert(rc==SQLITE_OK);
SAFE_SQLITE3_STEP2(statement);
rc=sqlite3_clear_bindings(statement); assert(rc==SQLITE_OK);
@ -8698,34 +8700,42 @@ 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, max_lag_ms, check_interval_ms, check_timeout_ms, writer_is_also_reader, new_reader_weight, comment) VALUES (%d, %d, %d, %d, %d, %d, %d, %d, '%s')";
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')";
for (i=0; i< count; i++) {
const Setting &line = mysql_aws_aurora_hostgroups[i];
int writer_hostgroup;
int reader_hostgroup;
int active=1; // default
int aurora_port;
int max_lag_ms;
int check_interval_ms;
int check_timeout_ms;
int writer_is_also_reader;
int new_reader_weight;
std::string comment="";
std::string endpoint_address="";
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;
if (line.lookupValue("max_lag_ms", max_lag_ms)==false) max_lag_ms=600000;
if (line.lookupValue("check_interval_ms", check_interval_ms)==false) check_interval_ms=1000;
if (line.lookupValue("check_timeout_ms", check_timeout_ms)==false) check_timeout_ms=1000;
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);
char *o1=strdup(comment.c_str());
char *o=escape_string_single_quotes(o1, false);
char *query=(char *)malloc(strlen(q)+strlen(o)+256); // 128 vs sizeof(int)*8
sprintf(query,q, writer_hostgroup, reader_hostgroup, active, max_lag_ms, check_interval_ms, check_timeout_ms, writer_is_also_reader, new_reader_weight, o);
char *p1=strdup(endpoint_address.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);
//fprintf(stderr, "%s\n", query);
admindb->execute(query);
if (o!=o1) free(o);
free(o1);
if (p!=p1) free(p);
free(p1);
free(query);
rows++;
}
@ -9675,7 +9685,12 @@ void ProxySQL_Admin::enable_aurora_testing() {
for (unsigned int j=1; j<4; j++) {
proxy_info("Admin is enabling AWS Aurora Testing using SQLite3 Server and HGs 127%d and 127%d\n" , j*2-1 , j*2);
for (unsigned int i=0; i<num_aurora_servers; i++) {
string serverid = "127.0." + std::to_string(j) + "." + std::to_string(i+11);
string serverid = "";
if (j==1) {
serverid = "host." + std::to_string(j) + "." + std::to_string(i+11) + ".aws-test.com";
} else {
serverid = "127.0." + std::to_string(j) + "." + std::to_string(i+11);
}
string sessionid= "";
sessionid = "b80ef4b4-" + serverid + "-aa01";
rc=sqlite3_bind_int64(statement, 1, 1270+j*2 ); assert(rc==SQLITE_OK);
@ -9688,7 +9703,7 @@ void ProxySQL_Admin::enable_aurora_testing() {
}
}
sqlite3_finalize(statement);
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 (1271, 1272, 1, 25, 120, 90, 1, 1, 'Automated Aurora Testing Cluster 1')");
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, 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')");
load_mysql_servers_to_runtime();

@ -778,8 +778,12 @@ void SQLite3_Server::populate_aws_aurora_table(MySQL_Session *sess) {
proxy_info("Simulating a failover for AWS Aurora cluster %d , HGs (%d:%d)\n", cluster_id, 1270 + cluster_id*2+1 , 1270 + cluster_id*2+2);
}
for (unsigned int i=0; i<num_aurora_servers[cluster_id]; i++) {
string serverid = "127.0." + std::to_string(cluster_id+1) + "." + std::to_string(i+11);
string serverid = "";
if (cluster_id==0) {
serverid = "host." + std::to_string(cluster_id+1) + "." + std::to_string(i+11);
} else {
serverid = "127.0." + std::to_string(cluster_id+1) + "." + std::to_string(i+11);
}
string sessionid= "";
float lag_ms = 0;
if (i==cur_aurora_writer[cluster_id]) {

Loading…
Cancel
Save