Skip to content

Commit

Permalink
Fix skipping sessions in idle threads iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonip committed Mar 19, 2019
1 parent 2155de9 commit e285dce
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2702,14 +2702,13 @@ void MySQL_Thread::run() {
int r=rand()%(GloMTH->num_threads);
MySQL_Thread *thr=GloMTH->mysql_threads_idles[r].worker;
if (shutdown==0 && thr->shutdown==0 && idle_mysql_sessions->len) {
unsigned int ims=0;
pthread_mutex_lock(&thr->myexchange.mutex_idles);
bool empty_queue=true;
if (thr->myexchange.idle_mysql_sessions->len) {
// there are already sessions in the queues. We assume someone already notified worker 0
empty_queue=false;
}
for (ims=0; ims<idle_mysql_sessions->len; ims++) {
while (idle_mysql_sessions->len) {
MySQL_Session *mysess=(MySQL_Session *)idle_mysql_sessions->remove_index_fast(0);
thr->myexchange.idle_mysql_sessions->add(mysess);
}
Expand Down Expand Up @@ -3019,9 +3018,8 @@ void MySQL_Thread::run() {
MySQL_Thread *thr=GloMTH->mysql_threads[w].worker;
if (resume_mysql_sessions->len) {
pthread_mutex_lock(&thr->myexchange.mutex_resumes);
unsigned int ims;
if (shutdown==0 && thr->shutdown==0)
for (ims=0; ims<resume_mysql_sessions->len; ims++) {
while (resume_mysql_sessions->len) {
MySQL_Session *mysess=(MySQL_Session *)resume_mysql_sessions->remove_index_fast(0);
thr->myexchange.resume_mysql_sessions->add(mysess);
}
Expand Down

0 comments on commit e285dce

Please sign in to comment.