hachikuji commented on a change in pull request #10909:
URL: https://github.com/apache/kafka/pull/10909#discussion_r679391787



##########
File path: raft/src/main/java/org/apache/kafka/raft/ReplicatedCounter.java
##########
@@ -61,10 +61,12 @@ public synchronized void increment() {
 
         int epoch = claimedEpoch.getAsInt();
         uncommitted += 1;
-        Long offset = client.scheduleAppend(epoch, singletonList(uncommitted));
-        if (offset != null) {
+        try {
+            long offset = client.scheduleAppend(epoch, 
singletonList(uncommitted));
             log.debug("Scheduled append of record {} with epoch {} at offset 
{}",
                 uncommitted, epoch, offset);
+        } catch (IllegalStateException e) {

Review comment:
       How about we catch `Exception` generally? 

##########
File path: 
raft/src/main/java/org/apache/kafka/raft/internals/BatchAccumulator.java
##########
@@ -148,7 +150,7 @@ private Long append(int epoch, List<T> records, boolean 
isAtomic) {
                 }
 
                 if (batch == null) {
-                    return null;
+                    throw new IllegalStateException("Append failed because we 
failed to allocate memory to write the batch");

Review comment:
       I wonder if it is worthwhile introducing some custom raft exception 
types for these two cases. At a minimum, that would let us improve the 
assertions. Maybe `NotLeaderException` and `BufferAllocationException` or 
something like that?




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