Lalant commented on code in PR #7820:
URL: https://github.com/apache/ignite-3/pull/7820#discussion_r3014673203


##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlApiBaseTest.java:
##########
@@ -736,6 +743,88 @@ public void 
runtimeErrorInQueryCausesTransactionToFail(String query) {
                 "Transaction is already finished due to an error");
     }
 
+    @Test
+    public void 
runtimeErrorReturnsSameTransactionErrorBeforeAndAfterRollbackCompletion() 
throws Exception {
+        sql("CREATE TABLE tst(id INTEGER PRIMARY KEY, val INTEGER)");
+
+        IgniteSql sql = igniteSql();
+
+        Transaction tx = igniteTx().begin();
+        UUID txId = tx instanceof InternalTransaction ? ((InternalTransaction) 
tx).id() : null;
+
+        // Enlist enough operations to make rollback non-trivial.
+        for (int i = 0; i < 100; i++) {
+            execute(tx, sql, "INSERT INTO tst VALUES (?, ?)", i, i);
+        }
+
+        assertThrowsSqlException(
+                Sql.RUNTIME_ERR,
+                "Division by zero",
+                () -> execute(tx, sql, "SELECT val / 0 FROM tst WHERE id = ?", 
0)
+        );
+
+        IgniteException[] immediateExceptions = new IgniteException[5];
+        for (int i = 0; i < immediateExceptions.length; i++) {
+            immediateExceptions[i] = (IgniteException) assertThrowsWithCause(
+                    () -> executeForRead(sql, tx, "SELECT * FROM tst WHERE id 
= ?", 1),
+                    IgniteException.class
+            );
+        }
+
+        if (txId != null) {
+            assertTrue(waitForCondition(() -> {
+                TxStateMeta meta = txManager().stateMeta(txId);
+
+                return meta != null && TxState.isFinalState(meta.txState());
+            }, 5_000), "Expected transaction to reach final state");
+        } else {
+            // Client transaction API doesn't expose internal tx id, wait a 
bit to compare with a later request.
+            Thread.sleep(500);

Review Comment:
   Fixed



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to