[
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.
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.
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.
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
@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());
}
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.
> 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.
>
> 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)