Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,21 @@ protected void closeChannel() {
}
}

/**
* kill connection by other thread
*/
protected void killConnection() {
isKilled = true;
// Close channel to break connection with client
closeChannel();
returnRows = 0;
deleteTempTable();
Env.getCurrentEnv().unregisterSessionInfo(this.sessionId);
}

/**
* kill connection by self
*/
public void cleanup() {
closeChannel();
threadLocalInfo.remove();
Expand Down Expand Up @@ -1024,16 +1039,10 @@ public void kill(boolean killConnection) {
killConnection);

if (killConnection) {
isKilled = true;
// Close channel to break connection with client
closeChannel();
killConnection();
}
// Now, cancel running query.
cancelQuery(new Status(TStatusCode.CANCELLED, "cancel query by user from " + getRemoteHostPortString()));
// Clean up after cancelQuery to avoid needing session variables etc. inside cancelQuery
if (killConnection) {
cleanup();
}
}

// kill operation with no protect by timeout.
Expand All @@ -1042,9 +1051,7 @@ private void killByTimeout(boolean killConnection) {
LOG.warn("kill wait timeout connection, connection type: {}, connectionId: {}, remote: {}, "
+ "wait timeout: {}",
getConnectType(), connectionId, getRemoteHostPortString(), sessionVariable.getWaitTimeoutS());
isKilled = true;
// Close channel to break connection with client
closeChannel();
killConnection();
}
// Now, cancel running query.
// cancelQuery by time out
Expand All @@ -1057,10 +1064,6 @@ private void killByTimeout(boolean killConnection) {
executorRef.cancel(new Status(TStatusCode.TIMEOUT,
"query is timeout, killed by timeout checker"));
}
// Clean up after cancelQuery to avoid needing session variables etc. inside cancelQuery
if (killConnection) {
cleanup();
}
}

public void cancelQuery(Status cancelReason) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,10 @@ public void kill(boolean killConnection) {
LOG.warn("kill query from {}, kill flight sql connection: {}", getRemoteHostPortString(), killConnection);

if (killConnection) {
isKilled = true;
// Close channel and break connection with client.
closeChannel();
killConnection();
}
// Now, cancel running query.
cancelQuery(new Status(TStatusCode.CANCELLED, "arrow flight query killed by user"));
// Clean up after cancelQuery to avoid needing session variables etc. inside cancelQuery
if (killConnection) {
cleanup();
}
}

@Override
Expand Down
Loading