guozhangwang commented on a change in pull request #9569:
URL: https://github.com/apache/kafka/pull/9569#discussion_r520924649



##########
File path: core/src/main/scala/kafka/server/KafkaApis.scala
##########
@@ -609,6 +609,12 @@ class KafkaApis(val requestChannel: RequestChannel,
 
       mergedResponseStatus.forKeyValue { (topicPartition, status) =>
         if (status.error != Errors.NONE) {
+          if (status.error == Errors.PRODUCER_FENCED) {

Review comment:
       I feel this is not the right place to fix on broker: if we think produce 
request should never see a fenced producer exception, we should just modify 
`ProducerStateManager#checkProducerEpoch` to throw 
`InvalidProducerEpochException` instead.

##########
File path: 
clients/src/main/java/org/apache/kafka/common/internals/InvalidProducerEpochException.java
##########
@@ -16,14 +16,15 @@
  */
 package org.apache.kafka.common.internals;
 
-import org.apache.kafka.common.errors.RetriableException;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.common.errors.ApiException;
 
 /**
  * This exception indicates that the produce request sent to the partition 
leader
- * contains a non-matching producer epoch. When encountering this exception, 
the ongoing transaction
- * will be aborted and can be retried.
+ * contains a non-matching producer epoch. When encountering this exception, 
user should abort the ongoing transaction
+ * by calling {@link KafkaProducer#abortTransaction()} to reinitialize the 
producer state.
  */
-public class InvalidProducerEpochException extends RetriableException {

Review comment:
       If we are going to expose this exception, then 1) it cannot be in the 
internals package, 2) public API javadocs should include this exception, also 
explains what users should do when getting this error. 3) KIP-588 should 
include this since it is now a publicly throwable exception.




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

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


Reply via email to