Skip to content

Commit 4252a69

Browse files
authored
Merge pull request #5087 from sysown/v3.0_fix_issue_5086
Fixed: Client hangs after executing PROXYSQL RESTART and attempt reconnection
2 parents ae96637 + 8d8577b commit 4252a69

File tree

6 files changed

+27
-20
lines changed

6 files changed

+27
-20
lines changed

include/PgSQL_HostGroups_Manager.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,6 @@ class PgSQL_HostGroups_Manager : public Base_HostGroups_Manager<PgSQL_HGC> {
557557

558558
SQLite3_result* incoming_pgsql_servers_v2;
559559

560-
std::thread *HGCU_thread;
561-
562-
std::thread *GTID_syncer_thread;
563-
//pthread_t GTID_syncer_thread_id;
564-
//pthread_t HGCU_thread_id;
565-
566560
char rand_del[8];
567561
pthread_mutex_t pgsql_errors_mutex;
568562
umap_pgsql_errors pgsql_errors_umap;

include/proxysql_glovars.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class ProxySQL_GlobalVariables {
137137
char* gr_bootstrap_ssl_key;
138138
char* gr_bootstrap_ssl_mode;
139139
pthread_mutex_t ext_glomth_mutex;
140-
140+
pthread_mutex_t ext_glopth_mutex;
141141
bool ssl_keylog_enabled;
142142
} global;
143143
struct mysql {

lib/PgSQL_HostGroups_Manager.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -740,19 +740,11 @@ PgSQL_HostGroups_Manager::PgSQL_HostGroups_Manager() {
740740
}
741741

742742
void PgSQL_HostGroups_Manager::init() {
743-
// gtid initialization;
744-
//GTID_syncer_thread = new std::thread(&GTID_syncer_run);
745-
GTID_syncer_thread = nullptr;
746-
747-
//pthread_create(&GTID_syncer_thread_id, NULL, GTID_syncer_run , NULL);
743+
// do nothing here
748744
}
749745

750746
void PgSQL_HostGroups_Manager::shutdown() {
751-
HGCU_thread->join();
752-
delete HGCU_thread;
753-
ev_async_send(gtid_ev_loop, gtid_ev_async);
754-
GTID_syncer_thread->join();
755-
delete GTID_syncer_thread;
747+
// do nothing here
756748
}
757749

758750
PgSQL_HostGroups_Manager::~PgSQL_HostGroups_Manager() {

lib/PgSQL_Thread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3736,7 +3736,7 @@ void PgSQL_Thread::process_all_sessions() {
37363736
}
37373737

37383738
void PgSQL_Thread::refresh_variables() {
3739-
pthread_mutex_lock(&GloVars.global.ext_glomth_mutex);
3739+
pthread_mutex_lock(&GloVars.global.ext_glopth_mutex);
37403740
if (GloPTH == NULL) {
37413741
return;
37423742
}
@@ -3981,7 +3981,7 @@ void PgSQL_Thread::refresh_variables() {
39813981
#endif // DEBUG
39823982
*/
39833983
GloPTH->wrunlock();
3984-
pthread_mutex_unlock(&GloVars.global.ext_glomth_mutex);
3984+
pthread_mutex_unlock(&GloVars.global.ext_glopth_mutex);
39853985
}
39863986

39873987
PgSQL_Thread::PgSQL_Thread() {

lib/ProxySQL_GloVars.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ ProxySQL_GlobalVariables::ProxySQL_GlobalVariables() :
209209
pthread_mutex_init(&global.start_mutex,NULL);
210210
pthread_mutex_init(&checksum_mutex,NULL);
211211
pthread_mutex_init(&global.ext_glomth_mutex,NULL);
212+
pthread_mutex_init(&global.ext_glopth_mutex, NULL);
212213
epoch_version = 0;
213214
checksums_values.updates_cnt = 0;
214215
checksums_values.dumped_at = 0;

src/main.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,16 @@ void ProxySQL_Main_shutdown_all_modules() {
12481248
pthread_mutex_unlock(&GloVars.global.ext_glomth_mutex);
12491249
#ifdef DEBUG
12501250
std::cerr << "GloMTH shutdown in ";
1251+
#endif
1252+
}
1253+
if (GloPTH) {
1254+
cpu_timer t;
1255+
pthread_mutex_lock(&GloVars.global.ext_glopth_mutex);
1256+
delete GloPTH;
1257+
GloPTH = NULL;
1258+
pthread_mutex_unlock(&GloVars.global.ext_glopth_mutex);
1259+
#ifdef DEBUG
1260+
std::cerr << "GloPTH shutdown in ";
12511261
#endif
12521262
}
12531263
if (GloMyLogger) {
@@ -1277,12 +1287,22 @@ void ProxySQL_Main_shutdown_all_modules() {
12771287
std::cerr << "GloAdmin shutdown in ";
12781288
#endif
12791289
}
1290+
if (MyHGM)
12801291
{
12811292
cpu_timer t;
12821293
MyHGM->shutdown();
12831294
delete MyHGM;
12841295
#ifdef DEBUG
1285-
std::cerr << "GloHGM shutdown in ";
1296+
std::cerr << "GloMyHGM shutdown in ";
1297+
#endif
1298+
}
1299+
if (PgHGM)
1300+
{
1301+
cpu_timer t;
1302+
PgHGM->shutdown();
1303+
delete PgHGM;
1304+
#ifdef DEBUG
1305+
std::cerr << "GloPgHGM shutdown in ";
12861306
#endif
12871307
}
12881308
if (GloMyStmt) {

0 commit comments

Comments
 (0)