chia7712 commented on code in PR #24172:
URL: https://github.com/apache/kafka/pull/24172#discussion_r4566747468


##########
clients/src/main/java/org/apache/kafka/common/record/LazyDownConversionRecordsSend.java:
##########
@@ -90,6 +90,13 @@ public int writeTo(TransferableChannel channel, int 
previouslyWritten, int remai
                 // offset of the batch which has the unsupported compression 
type. At that time, we will
                 // send back the UNSUPPORTED_COMPRESSION_TYPE error which will 
allow the consumer to fail gracefully.
                 convertedRecords = buildOverflowBatch(remaining);
+            } catch (RecordSizeLimitExceededException e) {
+                // We have encountered a record whose decompressed body 
exceeds the topic's
+                // max.decompressed.message.bytes. As above, we have already 
committed to the fetch size, so we send
+                // an overflow batch. The consumer will then fetch from the 
offset of the offending batch, at which
+                // point the eager conversion of the first batch fails and the 
INVALID_RECORD error is returned.
+                log.warn("Failed to down-convert records for partition {}, 
sending an overflow batch instead", topicPartition(), e);
+                convertedRecords = buildOverflowBatch(remaining);

Review Comment:
   `buildOverflowBatch` fills at most 128KB, so when remaining is larger, the 
next `writeTo` call will call `hasNext` again and then throw 
`IllegalStateException`, since the iterator stays in the failed state after 
`makeNext` throws. I guess it needs an error flag to skip the iterator.
   
   ```java
       public boolean hasNext() {
           switch (state) {
               case FAILED:
                   throw new IllegalStateException("Iterator is in failed 
state");
               case DONE:
                   return false;
               case READY:
                   return true;
               default:
                   return maybeComputeNext();
           }
       }
   ```



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