From 6c2e0dd93a8115a5cfb869b4cc75a26cd5a1487b Mon Sep 17 00:00:00 2001 From: Carson Ip Date: Thu, 14 Mar 2019 21:46:16 +0800 Subject: [PATCH] Do not move throttled session to epoll Epoll thread does not poll for EPOLLOUT. If a throttled session with pending data out is moved to epoll thread, the session will stay in epoll thread indefinitely, causing a hang observed by client. Fix by not moving throttled session to epoll thread. Fix #1939 --- lib/MySQL_Thread.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 698f704905..62aa194860 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -2606,7 +2606,9 @@ void MySQL_Thread::run() { if (myds->DSS==STATE_SLEEP && myds->sess->status==WAITING_CLIENT_DATA) { unsigned long long _tmp_idle = mypolls.last_recv[n] > mypolls.last_sent[n] ? mypolls.last_recv[n] : mypolls.last_sent[n] ; if (_tmp_idle < ( (curtime > (unsigned int)mysql_thread___session_idle_ms * 1000) ? (curtime - mysql_thread___session_idle_ms * 1000) : 0)) { - if (myds->sess->client_myds == myds && myds->PSarrayOUT->len==0 && (myds->queueOUT.head - myds->queueOUT.tail)==0 ) { // extra check + // make sure data stream has no pending data out and session is not throttled (#1939) + // because epoll thread does not handle data stream with data out + if (myds->sess->client_myds == myds && !myds->available_data_out() && myds->sess->pause_until <= curtime) { unsigned int j; int conns=0; for (j=0;jsess->mybes->len;j++) {