Merge pull request #2957 from sysown/v2.1.0-2916_2918_2919_2920_2921

Fixes #2916, #2918, #2919, #2920 and #2921
pull/3025/head
René Cannaò 6 years ago committed by GitHub
commit 3981e9ec3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,8 +7,8 @@ class SQLite3DB;
extern const char* config_header;
class ProxySQL_Config {
SQLite3DB* admindb;
public:
SQLite3DB* admindb;
ProxySQL_Config(SQLite3DB* db);
virtual ~ProxySQL_Config();

@ -92,6 +92,7 @@ class ProxySQL_GlobalVariables {
#ifdef PROXYSQLCLICKHOUSE
bool clickhouse_server;
#endif /* PROXYSQLCLICKHOUSE */
pthread_mutex_t ext_glomth_mutex;
} global;
struct mysql {
char *server_version;

@ -22,8 +22,8 @@ public:
};
class ProxySQL_Restapi {
SQLite3DB* admindb;
public:
SQLite3DB* admindb;
ProxySQL_Restapi(SQLite3DB* db);
virtual ~ProxySQL_Restapi();

@ -4733,6 +4733,7 @@ void MySQL_Thread::process_all_sessions() {
}
void MySQL_Thread::refresh_variables() {
pthread_mutex_lock(&GloVars.global.ext_glomth_mutex);
if (GloMTH==NULL) {
return;
}
@ -4912,6 +4913,7 @@ void MySQL_Thread::refresh_variables() {
mysql_thread___session_debug=(bool)GloMTH->get_variable_int((char *)"session_debug");
#endif /* DEBUG */
GloMTH->wrunlock();
pthread_mutex_unlock(&GloVars.global.ext_glomth_mutex);
}
MySQL_Thread::MySQL_Thread() {

@ -778,11 +778,17 @@ int ProxySQL_Test___GetDigestTable(bool reset, bool use_swap) {
ProxySQL_Config& ProxySQL_Admin::proxysql_config() {
static ProxySQL_Config instance = ProxySQL_Config(admindb);
if (instance.admindb != admindb) {
instance.admindb = admindb;
}
return instance;
}
ProxySQL_Restapi& ProxySQL_Admin::proxysql_restapi() {
static ProxySQL_Restapi instance = ProxySQL_Restapi(admindb);
if (instance.admindb != admindb) {
instance.admindb = admindb;
}
return instance;
}
@ -1200,7 +1206,13 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
rc=__sync_bool_compare_and_swap(&GloVars.global.nostart,1,0);
}
if (rc) {
// Set the status variable 'threads_initialized' to 0 because it's initialized back
// in main 'init_phase3'. After GloMTH have been initialized again.
__sync_bool_compare_and_swap(&GloMTH->status_variables.threads_initialized, 1, 0);
proxy_debug(PROXY_DEBUG_ADMIN, 4, "Starting ProxySQL following PROXYSQL START command\n");
while(__sync_fetch_and_add(&GloMTH->status_variables.threads_initialized, 0) == 1) {
usleep(1000);
}
SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL);
} else {
proxy_warning("ProxySQL was already started when received PROXYSQL START command\n");
@ -1231,6 +1243,17 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
GloMTH->commit();
glovars.reload=2;
__sync_bool_compare_and_swap(&glovars.shutdown,0,1);
// After setting the shutdown flag, we should wake all threads and wait for
// the shutdown phase to complete.
GloMTH->signal_all_threads(0);
while (__sync_fetch_and_add(&glovars.shutdown,0)==1) {
usleep(1000);
}
// After shutdown phase is completed, we must to send a 'OK' to the
// mysql client, otherwise, since this session might not be drop due
// to the waiting condition, the client wont disconnect and will
// keep forever waiting for acknowledgement.
SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL);
return false;
}
@ -4605,6 +4628,7 @@ void ProxySQL_Admin::vacuum_stats(bool is_admin) {
void *child_mysql(void *arg) {
if (GloMTH == nullptr) { return NULL; }
pthread_attr_t thread_attr;
size_t tmp_stack_size=0;

@ -100,6 +100,7 @@ ProxySQL_GlobalVariables::ProxySQL_GlobalVariables() :
// global.use_proxysql_mem=false;
pthread_mutex_init(&global.start_mutex,NULL);
pthread_mutex_init(&checksum_mutex,NULL);
pthread_mutex_init(&global.ext_glomth_mutex,NULL);
epoch_version = 0;
checksums_values.updates_cnt = 0;
checksums_values.dumped_at = 0;

@ -766,6 +766,7 @@ void * mysql_worker_thread_func(void *arg) {
worker->run();
//delete worker;
delete worker;
mysql_thread->worker=NULL;
// l_mem_destroy(__thr_sfp);
__sync_fetch_and_sub(&GloVars.statuses.stack_memory_mysql_threads,tmp_stack_size);
return NULL;
@ -1172,8 +1173,10 @@ void ProxySQL_Main_shutdown_all_modules() {
}
if (GloMTH) {
cpu_timer t;
pthread_mutex_lock(&GloVars.global.ext_glomth_mutex);
delete GloMTH;
GloMTH=NULL;
pthread_mutex_unlock(&GloVars.global.ext_glomth_mutex);
#ifdef DEBUG
std::cerr << "GloMTH shutdown in ";
#endif

Loading…
Cancel
Save