zhangstar333 commented on code in PR #69421:
URL: https://github.com/apache/doris/pull/69421#discussion_r4344743556
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java:
##########
@@ -779,6 +779,30 @@ public void setCommand(MysqlCommand command) {
this.command = command;
}
+ /** Reserve an idle MySQL connection before dispatching a newly received
packet. */
+ public synchronized boolean startMysqlCommand() {
+ if (isKilled) {
+ return false;
+ }
+ // COM_QUERY also covers the short interval before dispatch decodes
the command.
+ // Otherwise the shutdown thread could mistake a received packet for
an idle socket.
+ command = MysqlCommand.COM_QUERY;
+ return true;
+ }
+
+ /** Close an idle socket without cancelling an executor that has just
finished. */
+ public boolean closeIdleMysqlConnection() {
+ synchronized (this) {
+ if (getConnectType() != ConnectType.MYSQL || command !=
MysqlCommand.COM_SLEEP || isKilled) {
Review Comment:
https://github.com/apache/doris/pull/69421/changes/684fa2af3810f0d598f24aa057834f7f6d3fcf0b
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectScheduler.java:
##########
@@ -124,6 +124,22 @@ public Map<Integer, ConnectContext> getConnectionMap() {
return connectPoolMgr.getConnectionMap();
}
+ public void closeIdleMysqlConnections() {
+ for (ConnectContext context : getConnectionMap().values()) {
+ try {
+ context.closeIdleMysqlConnection();
+ } catch (Exception e) {
+ LOG.warn("failed to close idle MySQL connection {}",
context.getConnectionId(), e);
+ }
+ }
+ }
+
+ public boolean hasPendingFlightResults() {
+ return getConnectionMap().values().stream()
+ .anyMatch(context -> context.getConnectType() ==
ConnectContext.ConnectType.ARROW_FLIGHT_SQL
+ && context.getFlightSqlChannel().resultNum() > 0);
Review Comment:
https://github.com/apache/doris/pull/69421/changes/684fa2af3810f0d598f24aa057834f7f6d3fcf0b
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]