Ensure PgSQL_Threads_Handler and PgSQL_HostGroups_Manager objects are released when ProxySQL shuts down or restarts.

pull/5087/head
Rahim Kanji 8 months ago
parent ae96637af9
commit 8d8577b0ad

@ -557,12 +557,6 @@ class PgSQL_HostGroups_Manager : public Base_HostGroups_Manager<PgSQL_HGC> {
SQLite3_result* incoming_pgsql_servers_v2;
std::thread *HGCU_thread;
std::thread *GTID_syncer_thread;
//pthread_t GTID_syncer_thread_id;
//pthread_t HGCU_thread_id;
char rand_del[8];
pthread_mutex_t pgsql_errors_mutex;
umap_pgsql_errors pgsql_errors_umap;

@ -137,7 +137,7 @@ class ProxySQL_GlobalVariables {
char* gr_bootstrap_ssl_key;
char* gr_bootstrap_ssl_mode;
pthread_mutex_t ext_glomth_mutex;
pthread_mutex_t ext_glopth_mutex;
bool ssl_keylog_enabled;
} global;
struct mysql {

@ -740,19 +740,11 @@ PgSQL_HostGroups_Manager::PgSQL_HostGroups_Manager() {
}
void PgSQL_HostGroups_Manager::init() {
// gtid initialization;
//GTID_syncer_thread = new std::thread(&GTID_syncer_run);
GTID_syncer_thread = nullptr;
//pthread_create(&GTID_syncer_thread_id, NULL, GTID_syncer_run , NULL);
// do nothing here
}
void PgSQL_HostGroups_Manager::shutdown() {
HGCU_thread->join();
delete HGCU_thread;
ev_async_send(gtid_ev_loop, gtid_ev_async);
GTID_syncer_thread->join();
delete GTID_syncer_thread;
// do nothing here
}
PgSQL_HostGroups_Manager::~PgSQL_HostGroups_Manager() {

@ -3736,7 +3736,7 @@ void PgSQL_Thread::process_all_sessions() {
}
void PgSQL_Thread::refresh_variables() {
pthread_mutex_lock(&GloVars.global.ext_glomth_mutex);
pthread_mutex_lock(&GloVars.global.ext_glopth_mutex);
if (GloPTH == NULL) {
return;
}
@ -3981,7 +3981,7 @@ void PgSQL_Thread::refresh_variables() {
#endif // DEBUG
*/
GloPTH->wrunlock();
pthread_mutex_unlock(&GloVars.global.ext_glomth_mutex);
pthread_mutex_unlock(&GloVars.global.ext_glopth_mutex);
}
PgSQL_Thread::PgSQL_Thread() {

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

@ -1248,6 +1248,16 @@ void ProxySQL_Main_shutdown_all_modules() {
pthread_mutex_unlock(&GloVars.global.ext_glomth_mutex);
#ifdef DEBUG
std::cerr << "GloMTH shutdown in ";
#endif
}
if (GloPTH) {
cpu_timer t;
pthread_mutex_lock(&GloVars.global.ext_glopth_mutex);
delete GloPTH;
GloPTH = NULL;
pthread_mutex_unlock(&GloVars.global.ext_glopth_mutex);
#ifdef DEBUG
std::cerr << "GloPTH shutdown in ";
#endif
}
if (GloMyLogger) {
@ -1277,12 +1287,22 @@ void ProxySQL_Main_shutdown_all_modules() {
std::cerr << "GloAdmin shutdown in ";
#endif
}
if (MyHGM)
{
cpu_timer t;
MyHGM->shutdown();
delete MyHGM;
#ifdef DEBUG
std::cerr << "GloHGM shutdown in ";
std::cerr << "GloMyHGM shutdown in ";
#endif
}
if (PgHGM)
{
cpu_timer t;
PgHGM->shutdown();
delete PgHGM;
#ifdef DEBUG
std::cerr << "GloPgHGM shutdown in ";
#endif
}
if (GloMyStmt) {

Loading…
Cancel
Save