Skip to content

Commit

Permalink
Merge pull request #3633 from sysown/v2.2.2-to-v2.3.0-5_merge
Browse files Browse the repository at this point in the history
V2.2.2 to v2.3.0 5 merge , related to #3268
  • Loading branch information
renecannao committed Sep 17, 2021
2 parents 390da00 + e1e4977 commit 456bd23
Show file tree
Hide file tree
Showing 31 changed files with 1,484 additions and 270 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ src/*pem
binaries/*deb
binaries/*rpm
tools/eventslog_reader_sample
src/proxysql-save.cfg

proxysql-2.0.0/
docker/images/proxysql/rhel-compliant/rpmmacros
Expand Down
3 changes: 2 additions & 1 deletion include/MySQL_PreparedStatement.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ class MySQL_STMT_Manager_v14 {
public:
MySQL_STMT_Manager_v14();
~MySQL_STMT_Manager_v14();
MySQL_STMT_Global_info * find_prepared_statement_by_hash(uint64_t hash, bool lock=true);
//MySQL_STMT_Global_info * find_prepared_statement_by_hash(uint64_t hash, bool lock=true); // removed in 2.3
MySQL_STMT_Global_info * find_prepared_statement_by_hash(uint64_t hash);
MySQL_STMT_Global_info * find_prepared_statement_by_stmt_id(uint64_t id, bool lock=true);
void rdlock() { pthread_rwlock_rdlock(&rwlock_); }
void wrlock() { pthread_rwlock_wrlock(&rwlock_); }
Expand Down
4 changes: 0 additions & 4 deletions include/configfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ class ProxySQL_ConfigFile {
bool OpenFile(const char *);
void CloseFile();
bool ReadGlobals();
bool configVariable(const char *, const char *, int &, int, int, int, int);
bool configVariable(const char *, const char *, int64_t &, int64_t, int64_t, int64_t, int64_t);
bool configVariable(const char *, const char *, bool &, bool);
bool configVariable(const char *, const char *, char **, const char *);
};


Expand Down
2 changes: 0 additions & 2 deletions include/mysql_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class Variable {
char *value = (char*)"";
void fill_server_internal_session(json &j, int conn_num, int idx);
void fill_client_internal_session(json &j, int idx);
static const char set_name[SQL_NAME_LAST][64];
static const char proxysql_internal_session_name[SQL_NAME_LAST][64];
};

enum charset_action {
Expand Down
10 changes: 5 additions & 5 deletions include/proxysql_admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ class ProxySQL_Admin {
void flush_debug_filters_database_to_runtime(SQLite3DB *db);
#endif /* DEBUG */

void __insert_or_ignore_maintable_select_disktable();
// void __insert_or_ignore_maintable_select_disktable(); // commented in 2.3
void __insert_or_replace_maintable_select_disktable();
void __delete_disktable();
// void __delete_disktable(); // commented in 2.3 , unused
void __insert_or_replace_disktable_select_maintable();
void __attach_db(SQLite3DB *db1, SQLite3DB *db2, char *alias);

Expand Down Expand Up @@ -310,12 +310,12 @@ class ProxySQL_Admin {
void flush_mysql_query_rules__from_disk_to_memory();
void flush_mysql_firewall__from_memory_to_disk();
void flush_mysql_firewall__from_disk_to_memory();
void flush_mysql_variables__from_disk_to_memory();

// void flush_mysql_variables__from_disk_to_memory(); // commented in 2.3 because unused
void flush_mysql_variables__from_memory_to_disk();
void flush_admin_variables__from_disk_to_memory();
// void flush_admin_variables__from_disk_to_memory(); // commented in 2.3 because unused
void flush_admin_variables__from_memory_to_disk();
void flush_ldap_variables__from_memory_to_disk();

void load_mysql_servers_to_runtime();
void save_mysql_servers_from_runtime();
char * load_mysql_query_rules_to_runtime();
Expand Down
22 changes: 14 additions & 8 deletions lib/MySQL_HostGroups_Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3188,8 +3188,10 @@ MySQL_Connection * MySrvConnList::get_random_MyConn(MySQL_Session *sess, bool ff
conn=(MySQL_Connection *)conns->remove_index_fast(conn_found_idx);
break;
default: // this should never happen
// LCOV_EXCL_START
assert(0);
break;
// LCOV_EXCL_STOP
}
} else {
conn=(MySQL_Connection *)conns->remove_index_fast(i);
Expand Down Expand Up @@ -3284,8 +3286,10 @@ void MySQL_HostGroups_Manager::destroy_MyConn_from_pool(MySQL_Connection *c, boo
pthread_attr_setstacksize (&attr, 256*1024);
pthread_t pt;
if (pthread_create(&pt, &attr, &kill_query_thread, ka) != 0) {
// LCOV_EXCL_START
proxy_error("Thread creation\n");
assert(0);
// LCOV_EXCL_STOP
}
}
break;
Expand Down Expand Up @@ -3317,10 +3321,9 @@ void MySQL_HostGroups_Manager::add(MySrvC *mysrvc, unsigned int _hid) {
void MySQL_HostGroups_Manager::replication_lag_action(int _hid, char *address, unsigned int port, int current_replication_lag) {
GloAdmin->mysql_servers_wrlock();
wrlock();
int i,j;
for (i=0; i<(int)MyHostGroups->len; i++) {
MyHGC *myhgc=(MyHGC *)MyHostGroups->index(i);
if (_hid >= 0 && _hid!=(int)myhgc->hid) continue;
int j;
MyHGC *myhgc = MyHGC_find(_hid);
if (myhgc) {
for (j=0; j<(int)myhgc->mysrvs->cnt(); j++) {
MySrvC *mysrvc=(MySrvC *)myhgc->mysrvs->servers->index(j);
if (strcmp(mysrvc->address,address)==0 && mysrvc->port==port) {
Expand Down Expand Up @@ -3435,10 +3438,9 @@ int MySQL_HostGroups_Manager::get_multiple_idle_connections(int _hid, unsigned l
wrlock();
drop_all_idle_connections();
int num_conn_current=0;
int i,j, k;
for (i=0; i<(int)MyHostGroups->len; i++) {
MyHGC *myhgc=(MyHGC *)MyHostGroups->index(i);
if (_hid >= 0 && _hid!=(int)myhgc->hid) continue;
int j,k;
MyHGC* myhgc = MyHGC_find(_hid);
if (myhgc) {
for (j=0; j<(int)myhgc->mysrvs->cnt(); j++) {
MySrvC *mysrvc=(MySrvC *)myhgc->mysrvs->servers->index(j);
//PtrArray *pa=mysrvc->ConnectionsFree->conns;
Expand Down Expand Up @@ -3815,8 +3817,10 @@ SQLite3_result * MySQL_HostGroups_Manager::SQL3_Connection_Pool(bool _reset, int
pta[3]=strdup("SHUNNED_REPLICATION_LAG");
break;
default:
// LCOV_EXCL_START
assert(0);
break;
// LCOV_EXCL_STOP
}
sprintf(buf,"%u", mysrvc->ConnectionsUsed->conns_length());
pta[4]=strdup(buf);
Expand Down Expand Up @@ -4202,8 +4206,10 @@ void MySQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re
}
break;
default:
// LCOV_EXCL_START
assert(0);
break;
// LCOV_EXCL_STOP
}

__exit_read_only_action:
Expand Down
24 changes: 24 additions & 0 deletions lib/MySQL_Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,13 @@ class MySQL_Monitor_Connection_Pool {
return;
}
}
// LCOV_EXCL_START
assert(0);
// LCOV_EXCL_STOP
#endif // DEBUG
// LCOV_EXCL_START
return;
// LCOV_EXCL_STOP
};
};

Expand Down Expand Up @@ -305,7 +309,9 @@ void MySQL_Monitor_Connection_Pool::put_connection(char *hostname, int port, MYS
return;
}
}
// LCOV_EXCL_START
assert(0); // it didn't register it
// LCOV_EXCL_STOP
#else
return;
#endif // DEBUG
Expand All @@ -326,7 +332,9 @@ void MySQL_Monitor_Connection_Pool::put_connection(char *hostname, int port, MYS
return;
}
}
// LCOV_EXCL_START
assert(0);
// LCOV_EXCL_STOP
#endif // DEBUG
}

Expand Down Expand Up @@ -3255,38 +3263,52 @@ void * MySQL_Monitor::run() {
pthread_attr_setstacksize (&attr, 2048*1024);
pthread_t monitor_connect_thread;
if (pthread_create(&monitor_connect_thread, &attr, &monitor_connect_pthread,NULL) != 0) {
// LCOV_EXCL_START
proxy_error("Thread creation\n");
assert(0);
// LCOV_EXCL_STOP
}
pthread_t monitor_ping_thread;
if (pthread_create(&monitor_ping_thread, &attr, &monitor_ping_pthread,NULL) != 0) {
// LCOV_EXCL_START
proxy_error("Thread creation\n");
assert(0);
// LCOV_EXCL_STOP
}
pthread_t monitor_read_only_thread;
if (pthread_create(&monitor_read_only_thread, &attr, &monitor_read_only_pthread,NULL) != 0) {
// LCOV_EXCL_START
proxy_error("Thread creation\n");
assert(0);
// LCOV_EXCL_STOP
}
pthread_t monitor_group_replication_thread;
if (pthread_create(&monitor_group_replication_thread, &attr, &monitor_group_replication_pthread,NULL) != 0) {
// LCOV_EXCL_START
proxy_error("Thread creation\n");
assert(0);
// LCOV_EXCL_STOP
}
pthread_t monitor_galera_thread;
if (pthread_create(&monitor_galera_thread, &attr, &monitor_galera_pthread,NULL) != 0) {
// LCOV_EXCL_START
proxy_error("Thread creation\n");
assert(0);
// LCOV_EXCL_STOP
}
pthread_t monitor_aws_aurora_thread;
if (pthread_create(&monitor_aws_aurora_thread, &attr, &monitor_aws_aurora_pthread,NULL) != 0) {
// LCOV_EXCL_START
proxy_error("Thread creation\n");
assert(0);
// LCOV_EXCL_STOP
}
pthread_t monitor_replication_lag_thread;
if (pthread_create(&monitor_replication_lag_thread, &attr, &monitor_replication_lag_pthread,NULL) != 0) {
// LCOV_EXCL_START
proxy_error("Thread creation\n");
assert(0);
// LCOV_EXCL_STOP
}
while (shutdown==false && mysql_thread___monitor_enabled==true) {
unsigned int glover;
Expand Down Expand Up @@ -4636,8 +4658,10 @@ void * MySQL_Monitor::monitor_aws_aurora() {
hgs_array[i] = tmp_hgs_array[i];
proxy_info("Starting Monitor thread for AWS Aurora writer HG %u\n", hgs_array[i]);
if (pthread_create(&pthreads_array[i], NULL, monitor_AWS_Aurora_thread_HG, &hgs_array[i]) != 0) {
// LCOV_EXCL_START
proxy_error("Thread creation\n");
assert(0);
// LCOV_EXCL_STOP
}
}
free(tmp_hgs_array);
Expand Down
8 changes: 6 additions & 2 deletions lib/MySQL_PreparedStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,14 @@ MySQL_STMTs_local_v14::~MySQL_STMTs_local_v14() {


MySQL_STMT_Global_info *MySQL_STMT_Manager_v14::find_prepared_statement_by_hash(
uint64_t hash, bool lock) {
uint64_t hash) {
//uint64_t hash, bool lock) { // removed in 2.3
MySQL_STMT_Global_info *ret = NULL; // assume we do not find it
/* removed in 2.3
if (lock) {
pthread_rwlock_wrlock(&rwlock_);
}

*/
auto s = map_stmt_hash_to_info.find(hash);
if (s != map_stmt_hash_to_info.end()) {
ret = s->second;
Expand All @@ -736,9 +738,11 @@ MySQL_STMT_Global_info *MySQL_STMT_Manager_v14::find_prepared_statement_by_hash(
// __sync_fetch_and_add(&ret->ref_count_client, 1);
}

/* removed in 2.3
if (lock) {
pthread_rwlock_unlock(&rwlock_);
}
*/
return ret;
}

Expand Down
Loading

0 comments on commit 456bd23

Please sign in to comment.