mirror of
https://github.com/actiontech/dble.git
synced 2026-01-05 20:30:40 -06:00
fix timer thread hang inner 1790 & 2037 (#3287)
fix timer thread hang inner 1790 & 2037 (#3287)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2019 ActionTech.
|
||||
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
|
||||
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
|
||||
*/
|
||||
* Copyright (C) 2016-2019 ActionTech.
|
||||
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
|
||||
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
|
||||
*/
|
||||
package com.actiontech.dble.backend.mysql.nio.handler;
|
||||
|
||||
import com.actiontech.dble.backend.BackendConnection;
|
||||
@@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@@ -26,9 +27,14 @@ public class NewConnectionRespHandler implements ResponseHandler {
|
||||
|
||||
public BackendConnection getBackConn() throws IOException {
|
||||
lock.lock();
|
||||
boolean await = true;
|
||||
try {
|
||||
if (errMsg == null && backConn == null) {
|
||||
initiated.await();
|
||||
await = initiated.await(10000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
if (!await) {
|
||||
errMsg = "test conn timeout,TCP connection may be lost";
|
||||
LOGGER.warn(errMsg);
|
||||
}
|
||||
if (backConn == null) {
|
||||
throw new IOException(errMsg);
|
||||
@@ -117,6 +123,7 @@ public class NewConnectionRespHandler implements ResponseHandler {
|
||||
lock.unlock();
|
||||
}
|
||||
LOGGER.info("connectionClose " + conn);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -285,7 +285,6 @@ public abstract class AbstractConnection implements NIOConnection {
|
||||
if (got < 0) {
|
||||
if (this instanceof MySQLConnection) {
|
||||
((MySQLConnection) this).closeInner("stream closed");
|
||||
((MySQLConnection) this).onConnectFailed(new IOException("stream closed"));
|
||||
} else {
|
||||
this.close("stream closed");
|
||||
}
|
||||
|
||||
@@ -123,16 +123,10 @@ public final class NIOReactor {
|
||||
con.asyncRead();
|
||||
} catch (IOException e) {
|
||||
con.close("program err:" + e.toString());
|
||||
if (con instanceof MySQLConnection) {
|
||||
((MySQLConnection) con).onConnectFailed(e);
|
||||
}
|
||||
continue;
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("caught err:", e);
|
||||
con.close("program err:" + e.toString());
|
||||
if (con instanceof MySQLConnection) {
|
||||
((MySQLConnection) con).onConnectFailed(e);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user