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


##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:
##########
@@ -1164,23 +1180,59 @@ private TransactionalRequestResult 
handleCachedTransactionRequestResult(
         return result;
     }
 
+    /**
+     * Determines if an epoch bump can be triggered manually based on the api 
versions.
+     *
+     * <b>NOTE:</b>
+     * This method should only be used for transactional producers.
+     * For non-transactional producers epoch bumping is always allowed.
+     *
+     * <ol>
+     *   <li><b>Client-Triggered Epoch Bump</b>:
+     *          If the coordinator supports epoch bumping 
(initProducerIdVersion.maxVersion() >= 3),
+     *          client-triggered epoch bumping is allowed, returns true.
+     *          <code>clientSideEpochBumpTriggerRequired</code> must be set to 
true in this case.</li>
+     *
+     *   <li><b>No Epoch Bump Allowed</b>:
+     *          If the coordinator does not support epoch bumping, returns 
false.</li>
+     *
+     *   <li><b>Server-Triggered Only</b>:
+     *          When TransactionV2 is enabled, epoch bumping is handled 
automatically
+     *          by the server in EndTxn, so manual epoch bumping is not 
required, returns false.</li>
+     * </ol>
+     *
+     * @return true if a client-triggered epoch bump is allowed, otherwise 
false.
+     */
     // package-private for testing
-    boolean canBumpEpoch() {
-        if (!isTransactional()) {
-            return true;
-        }
+    boolean needToTriggerEpochBumpFromClient() {
+        return coordinatorSupportsBumpingEpoch && !isTransactionV2Enabled;
+    }
 
-        return coordinatorSupportsBumpingEpoch;
+    /**
+     * Determines if the coordinator can handle an abortable error.
+     * Recovering from an abortable error requires an epoch bump which can be 
triggered by the client
+     * or automatically taken care of at the end of every transaction 
(Transaction V2).
+     * Use <code>needToTriggerEpochBumpFromClient</code> to check whether the 
epoch bump needs to be triggered
+     * manually.
+     *
+     * <b>NOTE:</b>
+     * This method should only be used for transactional producers.

Review Comment:
   I think this note should say "there is no concept of abortable errors for 
idempotent producers."



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