Hi, Liu You mean at the same time, one statement can only hold one ResultSet in mysql-jdbc?
> -----原始邮件----- > 发件人: "″ 等灯.等灯`" <[email protected]> > 发送时间: 2019-11-06 17:41:28 (星期三) > 收件人: dev <[email protected]> > 抄送: > 主题: 回复: (IOTDB-291) Statement close operation may cause the whole > connection's resource to be released > > 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)
