kirktrue commented on code in PR #19489:
URL: https://github.com/apache/kafka/pull/19489#discussion_r2612164696
##########
storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:
##########
@@ -1602,13 +1602,34 @@ private MemoryRecords trimInvalidBytes(MemoryRecords
records, LogAppendInfo info
if (validBytes == records.sizeInBytes()) {
return records;
} else {
- // trim invalid bytes
+ // Duplicate the original buffer for trimming and logging purposes.
ByteBuffer validByteBuffer = records.buffer().duplicate();
+
+ // Log detailed information about trimmed bytes
+ validByteBuffer.position(validBytes);
+ byte[] invalidBytes = new byte[records.sizeInBytes() - validBytes];
+ validByteBuffer.get(invalidBytes);
+ String invalidBytesHex = bytesToHex(invalidBytes);
+
+ logger.warn("Trimming invalid bytes from message set for partition
{}. Original size: {} bytes, valid bytes: {}, trimmed bytes: {}. " +
Review Comment:
@junrao, is it sufficient to pass the `AppendOrigin` from `append()` to
`trimInvalidBytes()` and then check if it's equal to `AppendOrigin.CLIENT`?
--
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]