jolshan commented on code in PR #13591:
URL: https://github.com/apache/kafka/pull/13591#discussion_r1184407115


##########
clients/src/test/java/org/apache/kafka/clients/producer/internals/TransactionManagerTest.java:
##########
@@ -3405,6 +3408,53 @@ MAX_REQUEST_SIZE, ACKS_ALL, MAX_RETRIES, new 
SenderMetricsRegistry(new Metrics(t
         assertEquals(1, transactionManager.sequenceNumber(tp1).intValue());
     }
 
+    @Test
+    public void testMakeInvalidBackgroundTransitionFatal() {
+        doInitTransactions();
+        assertTrue(transactionManager.isTransactional());
+
+        assertThrows(IllegalStateException.class, () -> 
transactionManager.handleFailedBatch(batchWithValue(tp0, "test"), new 
NetworkException(), false, BACKGROUND));
+        assertTrue(transactionManager.hasFatalError());
+
+        // Step 4: validate that the transactions can't be started, committed
+        assertThrows(KafkaException.class, () -> 
transactionManager.beginTransaction());
+        assertThrows(KafkaException.class, () -> 
transactionManager.beginAbort(FOREGROUND));
+        assertThrows(KafkaException.class, () -> 
transactionManager.beginCommit());
+        assertThrows(KafkaException.class, () -> 
transactionManager.maybeAddPartition(tp0));
+        assertThrows(KafkaException.class, () -> 
transactionManager.initializeTransactions());
+        assertThrows(KafkaException.class, () -> 
transactionManager.sendOffsetsToTransaction(Collections.emptyMap(), new 
ConsumerGroupMetadata("fake-group-id")));
+    }
+
+    @Test
+    public void testForegroundInvalidStateTransitionIsRecoverable() {

Review Comment:
   🚀 



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to