Skip to content

Commit fc382b0

Browse files
Claudechernser
andauthored
Simplify KILL QUERY settings to always use empty QuerySettings
Use a fresh QuerySettings instance instead of copying default settings and removing session-related ones. This is simpler, more stable, and KILL QUERY doesn't need any special settings to execute. Agent-Logs-Url: https://github.com/ClickHouse/clickhouse-java/sessions/46c2fb43-ed16-4140-82e1-e9ecacc80711 Co-authored-by: chernser <827456+chernser@users.noreply.github.com>
1 parent edf105f commit fc382b0

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

jdbc-v2/src/main/java/com/clickhouse/jdbc/StatementImpl.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,9 @@ public void cancel() throws SQLException {
337337
+ (connection.onCluster ? "ON CLUSTER " + connection.cluster + " " : "")
338338
+ "WHERE query_id = '" + lastQueryId + "'";
339339

340-
// Create query settings without session to avoid "Session is locked by a concurrent client" error
341-
QuerySettings killQuerySettings = new QuerySettings();
342-
if (connection.getDefaultQuerySettings() != null) {
343-
killQuerySettings.getAllSettings().putAll(connection.getDefaultQuerySettings().getAllSettings());
344-
}
345-
killQuerySettings.setSessionId(null);
346-
killQuerySettings.setSessionCheck(false);
347-
348-
try (QueryResponse response = connection.getClient().query(sql, killQuerySettings).get()){
340+
// Use empty QuerySettings to avoid "Session is locked by a concurrent client" error
341+
// KILL QUERY doesn't need any special settings and should execute without session context
342+
try (QueryResponse response = connection.getClient().query(sql, new QuerySettings()).get()){
349343
LOG.debug("Query {} was killed by {}", lastQueryId, response.getQueryId());
350344
} catch (Exception e) {
351345
throw new SQLException(e);

0 commit comments

Comments
 (0)