sudeshwasnik commented on code in PR #12784:
URL: https://github.com/apache/kafka/pull/12784#discussion_r1006763859


##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ExactlyOnceWorkerSourceTask.java:
##########
@@ -280,16 +280,18 @@ private void commitTransaction() {
 
         // Commit the transaction
         // Blocks until all outstanding records have been sent and ack'd
-        try {
-            producer.commitTransaction();
-        } catch (Throwable t) {
-            log.error("{} Failed to commit producer transaction", 
ExactlyOnceWorkerSourceTask.this, t);
-            flushError.compareAndSet(null, t);
+        Throwable error = flushError.get();
+        if (error == null) {
+            try {
+                producer.commitTransaction();
+            } catch (Throwable t) {
+                log.error("{} Failed to commit producer transaction", 
ExactlyOnceWorkerSourceTask.this, t);
+                flushError.compareAndSet(null, t);
+            }
         }
-
         transactionOpen = false;
 
-        Throwable error = flushError.get();
+        error = flushError.get();

Review Comment:
   So we want to check if producer.commitTransaction itself resulted in error, 
ref - line 289



##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ExactlyOnceWorkerSourceTask.java:
##########
@@ -280,16 +280,18 @@ private void commitTransaction() {
 
         // Commit the transaction
         // Blocks until all outstanding records have been sent and ack'd
-        try {
-            producer.commitTransaction();
-        } catch (Throwable t) {
-            log.error("{} Failed to commit producer transaction", 
ExactlyOnceWorkerSourceTask.this, t);
-            flushError.compareAndSet(null, t);
+        Throwable error = flushError.get();
+        if (error == null) {
+            try {
+                producer.commitTransaction();
+            } catch (Throwable t) {
+                log.error("{} Failed to commit producer transaction", 
ExactlyOnceWorkerSourceTask.this, t);
+                flushError.compareAndSet(null, t);
+            }
         }
-
         transactionOpen = false;
 
-        Throwable error = flushError.get();
+        error = flushError.get();

Review Comment:
   we want to check if producer.commitTransaction itself resulted in error, ref 
- line 289



-- 
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