Handle the exception when cancel query failed.

This commit is contained in:
anikikong
2021-07-01 07:04:41 +00:00
committed by Gitee
parent 37ff7bf9c8
commit cc7372ca3d
2 changed files with 6 additions and 1 deletions

View File

@ -178,6 +178,7 @@ public abstract class QueryExecutorBase implements QueryExecutor {
} catch (IOException e) { } catch (IOException e) {
// Safe to ignore. // Safe to ignore.
LOGGER.trace("Ignoring exception on cancel request:", e); LOGGER.trace("Ignoring exception on cancel request:", e);
throw new SQLException("Cancel request on this connection failed");
} finally { } finally {
if (cancelStream != null) { if (cancelStream != null) {
try { try {

View File

@ -1143,7 +1143,11 @@ public class PgConnection implements BaseConnection {
@Override @Override
public void cancelQuery() throws SQLException { public void cancelQuery() throws SQLException {
checkClosed(); checkClosed();
try {
queryExecutor.sendQueryCancel(); queryExecutor.sendQueryCancel();
} catch (SQLException e) {
queryExecutor.close();
}
} }
@Override @Override