You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "korlov42 (via GitHub)" <gi...@apache.org> on 2025/07/11 07:12:46 UTC

[PR] WIP: refactoring [ignite-3]

korlov42 opened a new pull request, #6235:
URL: https://github.com/apache/ignite-3/pull/6235

   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25583 Sql. Implement direct mapping for explicit transactions [ignite-3]

Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #6235:
URL: https://github.com/apache/ignite-3/pull/6235#discussion_r2209533118


##########
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:
   Good catch! This looks like general problem with remote transaction since KV api fails as well. I filed a separate ticket for this case https://issues.apache.org/jira/browse/IGNITE-25921



##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlApiBaseTest.java:
##########
@@ -269,10 +270,12 @@ public void checkTransactionsWithDml() {
 
         // Outdated tx.
         Transaction outerTx0 = outerTx;
-        assertThrowsSqlException(
+        assertThrowsWithCode(
+                IgniteException.class,

Review Comment:
   doesn't look good indeed. Revered this change and introduced exception remapping instead



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25583 Sql. Implement direct mapping for explicit transactions [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25583 Sql. Implement direct mapping for explicit transactions [ignite-3]

Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 merged PR #6235:
URL: https://github.com/apache/ignite-3/pull/6235


-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25583 Sql. Implement direct mapping for explicit transactions [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
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 here 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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25583 Sql. Implement direct mapping for explicit transactions [ignite-3]

Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #6235:
URL: https://github.com/apache/ignite-3/pull/6235#discussion_r2206647966


##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/prepare/partitionawareness/PartitionAwarenessMetadataTest.java:
##########
@@ -165,9 +165,9 @@ private static Stream<Arguments> shortKeyMetadata() {
                 Arguments.of("SELECT * FROM t WHERE c1=? and c2=? and c3=3", null),
 
                 // KV PUT
-                Arguments.of("INSERT INTO t VALUES (?, ?, ?)",  dynamicParams(2)),
-                Arguments.of("INSERT INTO t (c1, c2, c3) VALUES (?, ?, ?)", dynamicParams(2)),
-                Arguments.of("INSERT INTO t (c3, c1, c2) VALUES (?, ?, ?)", dynamicParams(0)),
+                Arguments.of("INSERT INTO t VALUES (?, ?, ?)",  dynamicParamsTrackingRequired(2)),

Review Comment:
   lets also add :
   ```
   Arguments.of("SELECT * FROM t WHERE c3=? and c2=1", dynamicParams(0)),
   Arguments.of("SELECT * FROM t WHERE c1=1 and c2=? and c3=?", dynamicParams(1)),
   ```



##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/sql/ClientSqlExecuteRequest.java:
##########
@@ -79,12 +83,21 @@ public static CompletableFuture<ResponseWriter> process(
             ClientResourceRegistry resources,
             ClientHandlerMetricSource metrics,
             HybridTimestampTracker timestampTracker,
-            boolean sqlPartitionAwarenessSupported
+            boolean sqlPartitionAwarenessSupported,

Review Comment:
   append params to java doc plz



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25583 Sql. Implement direct mapping for explicit transactions [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #6235:
URL: https://github.com/apache/ignite-3/pull/6235#discussion_r2209239698


##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlApiBaseTest.java:
##########
@@ -269,10 +270,12 @@ public void checkTransactionsWithDml() {
 
         // Outdated tx.
         Transaction outerTx0 = outerTx;
-        assertThrowsSqlException(
+        assertThrowsWithCode(
+                IgniteException.class,

Review Comment:
   is it ok that thin client and embedded client produce different exceptions for the same statement?
   I mean the thin client doesn't wrap it in a SqlException, but the embedded does?



##########
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 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 ok?
   
   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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25583 Sql. Implement direct mapping for explicit transactions [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
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 here 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 ok?
   
   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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25583 Sql. Implement direct mapping for explicit transactions [ignite-3]

Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #6235:
URL: https://github.com/apache/ignite-3/pull/6235#discussion_r2209368767


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/sql/ClientSqlExecuteRequest.java:
##########
@@ -79,12 +83,21 @@ public static CompletableFuture<ResponseWriter> process(
             ClientResourceRegistry resources,
             ClientHandlerMetricSource metrics,
             HybridTimestampTracker timestampTracker,
-            boolean sqlPartitionAwarenessSupported
+            boolean sqlPartitionAwarenessSupported,

Review Comment:
   javadoc updated



##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/prepare/partitionawareness/PartitionAwarenessMetadataTest.java:
##########
@@ -165,9 +165,9 @@ private static Stream<Arguments> shortKeyMetadata() {
                 Arguments.of("SELECT * FROM t WHERE c1=? and c2=? and c3=3", null),
 
                 // KV PUT
-                Arguments.of("INSERT INTO t VALUES (?, ?, ?)",  dynamicParams(2)),
-                Arguments.of("INSERT INTO t (c1, c2, c3) VALUES (?, ?, ?)", dynamicParams(2)),
-                Arguments.of("INSERT INTO t (c3, c1, c2) VALUES (?, ?, ?)", dynamicParams(0)),
+                Arguments.of("INSERT INTO t VALUES (?, ?, ?)",  dynamicParamsTrackingRequired(2)),

Review Comment:
   done



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org