From 2bf816cd71f8456dc556db8fbbec9f4652141ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sat, 29 Oct 2016 16:23:21 +0000 Subject: [PATCH] Fix some race condition during PROXYSQL RESTART --- lib/MySQL_Thread.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 80da98161..ede694835 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -2109,7 +2109,7 @@ __run_skip_1: if (idle_maintenance_thread==false) { int r=rand()%(GloMTH->num_threads); MySQL_Thread *thr=GloMTH->mysql_threads_idles[r].worker; - if (idle_mysql_sessions->len) { + if (shutdown==0 && thr->shudown==0 idle_mysql_sessions->len) { unsigned int ims=0; //spin_wrlock(&GloMTH->rwlock_idles); pthread_mutex_lock(&thr->myexchange.mutex_idles); @@ -2497,6 +2497,7 @@ __run_skip_2: //spin_wrlock(&GloMTH->rwlock_resumes); pthread_mutex_lock(&thr->myexchange.mutex_resumes); unsigned int ims; + if (shutdown==0 && thr->shudown==0) for (ims=0; imslen; ims++) { MySQL_Session *mysess=(MySQL_Session *)resume_mysql_sessions->remove_index_fast(0); thr->myexchange.resume_mysql_sessions->add(mysess); @@ -2516,7 +2517,7 @@ __run_skip_2: } else { //spin_wrlock(&GloMTH->rwlock_resumes); pthread_mutex_lock(&thr->myexchange.mutex_resumes); - if (thr->myexchange.resume_mysql_sessions->len) { + if (shutdown==0 && thr->shudown==0 && thr->myexchange.resume_mysql_sessions->len) { //unsigned int w=rand()%(GloMTH->num_threads); //w++; unsigned char c=0;