[ https://issues.apache.org/jira/browse/IGNITE-19919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17753230#comment-17753230 ]
Pavel Pereslegin edited comment on IGNITE-19919 at 8/11/23 1:45 PM: -------------------------------------------------------------------- [~mzhuravkov], thanks for the contribution! Merged to the main branch ([3efece824520e4345cdd89014ebe6b867c18442d|https://github.com/apache/ignite-3/commit/3efece824520e4345cdd89014ebe6b867c18442d]). was (Author: xtern): [~mzhuravkov], thanks for the contribution! Merged to the main branch ([3efece824520e4345cdd89014ebe6b867c18442d|https://github.com/apache/ignite-3/commit/3efece824520e4345cdd89014ebe6b867c18442d]. > org.apache.ignite.sql.ResultSet#close should close implicit transaction if any > ------------------------------------------------------------------------------ > > Key: IGNITE-19919 > URL: https://issues.apache.org/jira/browse/IGNITE-19919 > Project: Ignite > Issue Type: Bug > Components: sql > Reporter: Alexander Lapin > Assignee: Maksim Zhuravkov > Priority: Major > Labels: ignite-3 > Time Spent: 1h > Remaining Estimate: 0h > > At the current moment, the transaction will be closed only if the cursor has > read all the data: > {code:java} > org.apache.ignite.internal.sql.engine.AsyncSqlCursorImpl#requestNextAsync{code} > in the case of an explicit ResultSet.close() call, the transaction will not > be closed. > > Repoducerers within org.apache.ignite.internal.sql.api.ItSqlSynchronousApiTest > {code:java} > @Test > public void resultSetCloseShouldFinishImplicitTransacion() throws > InterruptedException { > sql("CREATE TABLE TEST(ID INT PRIMARY KEY, VAL0 INT)"); > for (int i = 0; i < ROW_COUNT; ++i) { > sql("INSERT INTO TEST VALUES (?, ?)", i, i); > } > IgniteSql sql = igniteSql(); > Session ses = sql.sessionBuilder().defaultPageSize(2).build(); > ResultSet rs = ses.execute(null, "SELECT * FROM TEST"); > assertEquals(1, ((IgniteImpl) > CLUSTER_NODES.get(0)).txManager().pending()); > rs.close(); > assertEquals(0, ((IgniteImpl) > CLUSTER_NODES.get(0)).txManager().pending()); > }{code} > and > {code:java} > @Test > public void > resultSetCloseShouldFinishImplicitTransacionWithCursorTouchAfterClose() > throws InterruptedException { > sql("CREATE TABLE TEST(ID INT PRIMARY KEY, VAL0 INT)"); > for (int i = 0; i < ROW_COUNT; ++i) { > sql("INSERT INTO TEST VALUES (?, ?)", i, i); > } > IgniteSql sql = igniteSql(); > Session ses = sql.sessionBuilder().defaultPageSize(2).build(); > ResultSet rs = ses.execute(null, "SELECT * FROM TEST"); > assertEquals(1, ((IgniteImpl) > CLUSTER_NODES.get(0)).txManager().pending()); > Thread.sleep(300); // ResultSetImpl fetches next page in background, wait > to it to complete to avoid flakiness. > rs.close(); > assertThrowsWithCause(() -> rs.forEachRemaining(Object::hashCode), > CursorClosedException.class); > assertEquals(0, ((IgniteImpl) > CLUSTER_NODES.get(0)).txManager().pending()); > }{code} > Please, pay attention, that > resultSetCloseShouldFinishImplicitTransacionWithCursorTouchAfterClose faisl > only if client is used as entry point, meaning within > ItSqlClientSynchronousApiTest only, but > resultSetCloseShouldFinishImplicitTransacion fails both for client and > server, meaning both for ItSqlClientSynchronousApiTest and > ItSqlSynchronousApiTest. -- This message was sent by Atlassian Jira (v8.20.10#820010)