From 4e9de0a5ebbcb0a3c48c1fa95b45f6b898f7c91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Tue, 11 Oct 2016 10:53:08 +0000 Subject: [PATCH] Reduce the number of notifications to worker 0 --- lib/MySQL_Thread.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 21f98602b..c9fc670b1 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -1952,16 +1952,23 @@ __run_skip_1: if (idle_mysql_sessions->len) { unsigned int ims=0; spin_wrlock(&GloMTH->rwlock_idles); + bool empty_queue=true; + if (GloMTH->idle_mysql_sessions->len) { + // there are already sessions in the queues. We assume someone already notified worker 0 + empty_queue=false; + } for (ims=0; imslen; ims++) { MySQL_Session *mysess=(MySQL_Session *)idle_mysql_sessions->remove_index_fast(0); GloMTH->idle_mysql_sessions->add(mysess); } spin_wrunlock(&GloMTH->rwlock_idles); - unsigned char c=1; - MySQL_Thread *thr=GloMTH->mysql_threads[0].worker; - int fd=thr->pipefd[1]; - if (write(fd,&c,1)==-1) { - proxy_error("Error while signaling maintenance thread\n"); + if (empty_queue==true) { + unsigned char c=1; + MySQL_Thread *thr=GloMTH->mysql_threads[0].worker; + int fd=thr->pipefd[1]; + if (write(fd,&c,1)==-1) { + proxy_error("Error while signaling maintenance thread\n"); + } } } spin_wrlock(&GloMTH->rwlock_resumes);