Yuan Tian created IOTDB-291: ------------------------------- Summary: Statement close operation may cause the whole connection's resource to be released Key: IOTDB-291 URL: https://issues.apache.org/jira/browse/IOTDB-291 Project: Apache IoTDB Issue Type: Bug Reporter: Yuan Tian
The function closeClientOperation() in IoTDBStatement.java invokes the function closeOperation(TSCloseOperationReq) in TSServiceImpl. Because the queryId field in TSCloseOperationReq is set to be -1L, the releaseQueryResource function will release all the resources in that connection. {code:java} private void closeClientOperation() throws SQLException { try { if (operationHandle != null) { TSCloseOperationReq closeReq = new TSCloseOperationReq(operationHandle, -1); closeReq.setStmtId(stmtId); TSStatus closeResp = client.closeOperation(closeReq); RpcUtils.verifySuccess(closeResp); } } catch (Exception e) { throw new SQLException("Error occurs when closing statement.", e); } } {code} {code:java} private void releaseQueryResource(TSCloseOperationReq req) throws StorageEngineException { Map<Long, QueryContext> contextMap = contextMapLocal.get(); if (contextMap == null) { return; } if (req == null || req.queryId == -1) { // end query for all the query tokens created by current thread for (QueryContext context : contextMap.values()) { QueryResourceManager.getInstance().endQueryForGivenJob(context.getJobId()); } contextMapLocal.set(new HashMap<>()); } else { QueryResourceManager.getInstance() .endQueryForGivenJob(contextMap.remove(req.queryId).getJobId()); } } {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)