gaurav-narula opened a new pull request, #24172:
URL: https://github.com/apache/kafka/pull/24172

   The backport in PR #21417 did not cover decompression that happen while down 
converting records when handling old Fetch requests (v0-v3) as Kafka 4.x has 
dropped support for it. This PR introduces bounds for that code path.
   
   To handle it without changing the behaviour for genuinely corrupt records, 
the size checks now throw RecordSizeLimitExceededException (a subclass of 
`InvalidRecordException` in the non-public `org.apache.kafka.common.record` 
package) when the declared size is allocatable but exceeds the limit. Sizes 
that can never be allocated remain a plain InvalidRecordException. All other 
callers are unaffected and produce still returns INVALID_RECORD.
   
   First batch (converted eagerly in KafkaApis) return `INVALID_RECORD` for the 
partition and log a warning. Later batches (converted lazily while sending) log 
a warning and send an overflow batch, as is already done for unsupported 
compression types, so the consumer re-fetches from the offending batch and then 
receives `INVALID_RECORD`.
   
   `RecordsUtil#downConvert` and the `LazyDownConversionRecords` constructor 
now require the limit. `Records#downConvert`, used by the producer, passes 
`Records.SOFT_MAX_ARRAY_LENGTH`. As with the regular iterator, empty v2 batches 
are skipped without opening a decompression stream.


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