bvolpato opened a new pull request, #24339:
URL: https://github.com/apache/kafka/pull/24339

   When validating uncompressed v2 record batches on the broker,
   DefaultRecordBatch.skipKeyValueIterator currently falls back to
   DefaultRecord.readFrom(ByteBuffer), which slices ByteBuffers for every
   key and value and allocates Header arrays and RecordHeader objects only
   to discard them. LogValidator also allocates a validatedRecords list
   during v2 in-place compressed validation even when it is never read,
   along with per-batch error lists and Optional wrappers on valid batches.
   
   This change adds DefaultRecord.readPartiallyFrom(ByteBuffer, ...) to
   validate record and header framing while advancing buffer position past
   key, value, and header payloads without slicing or allocating header
   objects. DefaultRecordBatch.skipKeyValueIterator uses this path for
   uncompressed v2 batches, and LogValidator.assignOffsetsNonCompressed
   uses the skip iterator for magic v2+.
   
   In LogValidator, this also skips allocating and populating
   validatedRecords when in-place v2 compressed assignment is used, defers
   recordErrors allocation until an error occurs, unboxes
   expectedInnerOffset, hoists repeated batch header reads out of the
   record loop, and returns nullable ApiRecordError from private
   validation helpers.
   
   Framing, negative-length, header-count, and truncation checks are
   bounded strictly against the declared record end and match
   DefaultRecord.readFrom and the existing DataInput skip decoder.
   PartialDefaultRecord preserves key and value sizes so compacted-topic
   key checks behave identically, while v0/v1 and non-in-place compressed
   paths remain unchanged.
   
   Testing strategy: verified with DefaultRecord, DefaultRecordBatch,
   MemoryRecords, and LogValidator unit suites, extending tests to cover
   uncompressed skip-iterator field parity, invalid record framing, and
   key/header bounds checked against recordEnd when additional bytes follow
   in the same batch buffer, along with checkstyle, spotless, spotbugs, and
   RAT checks.
   
   An AI coding assistant was used to help prepare this change.
   


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