[
https://issues.apache.org/jira/browse/IGNITE-19919?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alexander Lapin updated IGNITE-19919:
-------------------------------------
Description:
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.
Repoducer 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}
was:
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.
Following part of
org.apache.ignite.internal.sql.api.ItSqlSynchronousApiTest#errors is a
reproducer:
{code:java}
// Cursor closed error.
{
ResultSet rs = ses.execute(null, "SELECT * FROM TEST");
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}
> 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
> Priority: Major
> Labels: ignite-3
>
> 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.
>
> Repoducer 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}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)