Lalant commented on code in PR #7820:
URL: https://github.com/apache/ignite-3/pull/7820#discussion_r3014671437
##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImplTest.java:
##########
@@ -950,6 +951,46 @@ void
testScanAfterExceptionalAbortThrowsFinishedWithErrCode() {
}
}
+ @Test
+ void testScanWhileFinishingAfterErrorThrowsFinishedWithErrCode() {
+ InternalTableImpl internalTable = newInternalTable(TABLE_ID, 1);
+
+ InternalTransaction tx = new ReadWriteTransactionImpl(
+ txManager,
+ mock(HybridTimestampTracker.class),
+ TestTransactionIds.newTransactionId(),
+ randomUUID(),
+ false,
+ 1,
+ null
+ );
+
+ UUID txId = tx.id();
+ IllegalStateException failure = new IllegalStateException("boom");
+
+ when(txManager.stateMeta(txId)).thenReturn(new
TxStateMetaFinishing(null, null, false, null, failure, null));
+ tx.rollbackWithExceptionAsync(new
TransactionException(TX_ALREADY_FINISHED_WITH_EXCEPTION_ERR,
+ "Transaction is already finished")).join();
+
+ Publisher<BinaryRow> publisher = internalTable.scan(VALID_PARTITION,
tx, VALID_INDEX_ID, IndexScanCriteria.unbounded());
+
+ CompletableFuture<Void> completed = new CompletableFuture<>();
+
+ publisher.subscribe(new BlackholeSubscriber(completed));
+
+ try {
+ completed.get(10, TimeUnit.SECONDS);
+ fail("Expected TransactionException but scan completed
successfully");
+ } catch (Exception e) {
+ Throwable unwrapped = unwrapCause(e);
+ assertThat("Error should be TransactionException", unwrapped,
is(instanceOf(TransactionException.class)));
+ TransactionException txEx = (TransactionException) unwrapped;
Review Comment:
Done
##########
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(() -> {
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]