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
Original file line number Diff line number Diff line change
Expand Up @@ -864,12 +864,30 @@ public PlSqlOperation getPlSqlOperation() {
return plSqlOperation;
}

/**
* This method is idempotent.
*/
protected void closeChannel() {
if (mysqlChannel != null) {
mysqlChannel.close();
}
}

/**
* 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 @@ -1004,9 +1022,7 @@ 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"));
Expand All @@ -1018,9 +1034,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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ 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"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

suite("test_temp_table_with_conn_timeout", "p0") {
String db = context.config.getDbNameByFile(context.file)
def tableName = "t_test_temp_table_with_conn_timeout"
String tempTableFullName
sql "select 1" // ensure db is created
connect(context.config.jdbcUser, context.config.jdbcPassword, context.config.jdbcUrl) {
sql"use ${db}"
sql """create temporary table ${tableName}(id int) properties("replication_num" = "1") """
def show_result = sql_return_maparray("show data")

show_result.each { row ->
if (row.TableName.contains(tableName)) {
tempTableFullName = row.TableName
}
}
assert tempTableFullName != null

// set session variable for a short connection timeout
sql "set interactive_timeout=5"
sql "set wait_timeout=5"

sleep(10*1000)
}

// temp table should not exist after session exit
def tables = sql_return_maparray("show data")
assert tables.find { it.TableName == tempTableFullName } == null
}