Skip to content

Commit c7892a6

Browse files
guyinyouguyinyou
andauthored
[ISSUE #9852] Print full message when CRC not found in properties (#9853)
When the error 'failed to check message CRC, not found CRC in properties' occurs, now it will print the full message content including topic, properties map, properties length, and full message hex for debugging purposes. Change-Id: I26d977e13802c5e69d01f16512e40d121dcff354 Co-developed-by: Cursor <noreply@cursor.com> Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
1 parent 90b0906 commit c7892a6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

store/src/main/java/org/apache/rocketmq/store/CommitLog.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,18 @@ public DispatchRequest checkMessageAndReturnSize(java.nio.ByteBuffer byteBuffer,
623623
return new DispatchRequest(-1, false/* success */);
624624
}
625625
} else {
626+
// Read full message for logging when error occurs
627+
ByteBuffer fullMessageBuffer = byteBuffer.duplicate();
628+
int messageStartPos = fullMessageBuffer.position() - totalSize;
629+
fullMessageBuffer.position(messageStartPos);
630+
fullMessageBuffer.limit(messageStartPos + totalSize);
631+
byte[] fullMessageBytes = new byte[totalSize];
632+
fullMessageBuffer.get(fullMessageBytes, 0, totalSize);
633+
634+
// Print full message and especially properties
626635
log.warn(
627-
"CommitLog#checkAndDispatchMessage: failed to check message CRC, not found CRC in properties");
636+
"CommitLog#checkAndDispatchMessage: failed to check message CRC, not found CRC in properties. topic={}, properties={}, propertiesLength={}, fullMessageHex={}",
637+
topic, propertiesMap != null ? propertiesMap.toString() : "null", propertiesLength, UtilAll.bytes2string(fullMessageBytes));
628638
return new DispatchRequest(-1, false/* success */);
629639
}
630640
}

0 commit comments

Comments
 (0)