jolshan commented on code in PR #17849:
URL: https://github.com/apache/kafka/pull/17849#discussion_r1849064321
##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:
##########
@@ -1164,23 +1164,42 @@ private TransactionalRequestResult
handleCachedTransactionRequestResult(
return result;
}
+ /**
+ * Determines if an epoch bump can be triggered manually based on the api
versions.
+ *
+ * <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>epochBumpTriggerRequired</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 canTriggerEpochBump() {
+ if (!coordinatorSupportsBumpingEpoch) {
+ return false;
}
-
- return coordinatorSupportsBumpingEpoch;
+ // If coordinator supports epoch bumping, client can trigger the bump
manually if TransactionsV2 is disabled.
+ return !isTransactionV2Enabled;
Review Comment:
Thanks Artem for writing this out clearly. It was something I missed on the
first design review.
--
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]