hi tiany, in cluster, how to save the statementId Map, and how to releases the resources corresponding of queryIds , i see mysql jdbc when call execute(sql) method , it will to implicitlyCloseAllOpenResults ,why not refer to this?? you want the client nested call ? ------------------ ???????? ------------------ ??????: "????"<[email protected]>; ????????: 2019??11??6??(??????) ????5:13 ??????: "dev"<[email protected]>;
????: Re: (IOTDB-291) Statement close operation may cause the whole connection's resource to be released Hi, I have solved the issued by maintaining a ThreadLocal<Map<Long, Set<Long>>> in the TSServiceImpl which is a map (statementId -> all queryIds in that statement). Every time the statement is closed, all the queryIds in that map should also be closed. However, when a ResultSet is closed, it only releases the resources corresponding to that queryId. When the connection is closed, the function closeSession() is invoked, it will release all the resource saved in that session thread. The PR link is https://github.com/apache/incubator-iotdb/pull/526. > -----????????----- > ??????: "Yuan Tian (Jira)" <[email protected]> > ????????: 2019-11-05 22:53:00 (??????) > ??????: [email protected] > ????: > ????: [jira] [Created] (IOTDB-291) Statement close operation may cause the whole connection's resource to be released > > 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)
