xtern commented on code in PR #6235: URL: https://github.com/apache/ignite-3/pull/6235#discussion_r2209338104
########## modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientSqlTest.java: ########## @@ -376,6 +392,109 @@ void testTransactionRollbackRevertsSqlUpdate() { assertEquals(1, res.currentPage().iterator().next().intValue(0)); } + @Test + void testExplicitTransactionKvCase() { + IgniteClient client = client(); + IgniteSql sql = client.sql(); + + sql.execute(null, "CREATE TABLE my_table (id INT PRIMARY KEY, val INT)"); + + // First, let's fill the table and check every row in implicit tx. + // This should also prepare partition awareness metadata. + int count = 10; + for (int i = 0; i < count; i++) { + try (ResultSet<?> ignored = sql.execute(null, "INSERT INTO my_table VALUES (?, ?)", i, i)) { + // No-op. + } + } + + for (int i = 0; i < count; i++) { + try (ResultSet<SqlRow> rs = sql.execute(null, "SELECT * FROM my_table WHERE id = ?", i)) { + assertEquals(i, rs.next().intValue(1)); + } + } + + // Now let's clean the table and do the same steps but within explicit tx. + + try (ResultSet<?> ignored = sql.execute(null, "DELETE FROM my_table")) { + // No-op. + } + + Transaction tx = client.transactions().begin(); + for (int i = 0; i < count; i++) { + try (ResultSet<?> ignored = sql.execute(tx, "INSERT INTO my_table VALUES (?, ?)", i, i)) { + // No-op. + } + } + + for (int i = 0; i < count; i++) { + try (ResultSet<SqlRow> rs = sql.execute(tx, "SELECT * FROM my_table WHERE id = ?", i)) { + assertEquals(i, rs.next().intValue(1)); + } + } + + // All just inserted rows should not be visible yet + for (int i = 0; i < count; i++) { + try (ResultSet<SqlRow> rs = sql.execute(null, "SELECT * FROM my_table WHERE id = ?", i)) { Review Comment: I changed a bit this test to use separate external RO-tx here. And test fails at this line with ``` Caused by: org.apache.ignite.internal.tx.LockException: IGN-TX-4 Failed to acquire a lock due to a possible deadlock [locker=019811d2-7bc3-0000-2722-841700000001, holder=019811d2-7b6f-0000-2722-841700000001] TraceId:789c7be0 ``` On the main branch such case passes. Is it expected? Full test case ```java @Test void testExplicitTransactionKvCase() { IgniteClient client = client(); IgniteSql sql = client.sql(); sql.execute(null, "CREATE TABLE my_table (id INT PRIMARY KEY, val INT)"); // First, let's fill the table and check every row in implicit tx. // This should also prepare partition awareness metadata. int count = 10; for (int i = 0; i < count; i++) { try (ResultSet<?> ignored = sql.execute(null, "INSERT INTO my_table VALUES (?, ?)", i, i)) { // No-op. } } for (int i = 0; i < count; i++) { try (ResultSet<SqlRow> rs = sql.execute(null, "SELECT * FROM my_table WHERE id = ?", i)) { assertEquals(i, rs.next().intValue(1)); } } // Now let's clean the table and do the same steps but within explicit tx. try (ResultSet<?> ignored = sql.execute(null, "DELETE FROM my_table")) { // No-op. } Transaction tx = client.transactions().begin(); Transaction tx1 = client.transactions().begin(new TransactionOptions().readOnly(true)); for (int i = 0; i < count; i++) { try (ResultSet<?> ignored = sql.execute(tx, "INSERT INTO my_table VALUES (?, ?)", i, i)) { // No-op. } } for (int i = 0; i < count; i++) { try (ResultSet<SqlRow> rs = sql.execute(tx, "SELECT * FROM my_table WHERE id = ?", i)) { assertEquals(i, rs.next().intValue(1)); } } // All just inserted rows should not be visible yet for (int i = 0; i < count; i++) { try (ResultSet<SqlRow> rs = sql.execute(tx1, "SELECT * FROM my_table WHERE id = ?", i)) { assertFalse(rs.hasNext()); } } tx.commit(); tx1.rollback(); // And now changes are published. for (int i = 0; i < count; i++) { try (ResultSet<SqlRow> rs = sql.execute(null, "SELECT * FROM my_table WHERE id = ?", i)) { assertEquals(i, rs.next().intValue(1)); } } } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org