Skip to content

Commit 2a2f54e

Browse files
author
guyinyou
committed
feat: print full message when CRC not found in properties
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 <[email protected]>
1 parent b77f2ab commit 2a2f54e

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
@@ -618,8 +618,18 @@ public DispatchRequest checkMessageAndReturnSize(java.nio.ByteBuffer byteBuffer,
618618
return new DispatchRequest(-1, false/* success */);
619619
}
620620
} else {
621+
// Read full message for logging when error occurs
622+
ByteBuffer fullMessageBuffer = byteBuffer.duplicate();
623+
int messageStartPos = fullMessageBuffer.position() - totalSize;
624+
fullMessageBuffer.position(messageStartPos);
625+
fullMessageBuffer.limit(messageStartPos + totalSize);
626+
byte[] fullMessageBytes = new byte[totalSize];
627+
fullMessageBuffer.get(fullMessageBytes, 0, totalSize);
628+
629+
// Print full message and especially properties
621630
log.warn(
622-
"CommitLog#checkAndDispatchMessage: failed to check message CRC, not found CRC in properties");
631+
"CommitLog#checkAndDispatchMessage: failed to check message CRC, not found CRC in properties. topic={}, properties={}, propertiesLength={}, fullMessageHex={}",
632+
topic, propertiesMap != null ? propertiesMap.toString() : "null", propertiesLength, UtilAll.bytes2string(fullMessageBytes));
623633
return new DispatchRequest(-1, false/* success */);
624634
}
625635
}

0 commit comments

Comments
 (0)