Skip to content

[ISSUE #11452] fix(common): name the file in the checkpoint crc mismatch message - #11453

Merged
RongtongJin merged 1 commit into
apache:developfrom
iloveeyjafjalla:codex/checkpoint-crc-message
Oct 19, 2026
Merged

RongtongJin merged 1 commit into
apache:developfrom
iloveeyjafjalla:codex/checkpoint-crc-message

Conversation

@iloveeyjafjalla

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Fixes #11452

Problem

CheckpointFile.read reports a crc32 mismatch with a file=%s label but passes expectedCrc32 into it, so a corrupted checkpoint prints a checksum where the path belongs and never labels the expected value:

Entries crc32 not match, file=823222925, truth=823222924

The path being read is in scope (read(String filePath)) when the message is built.

Change

- "Entries crc32 not match, file=%s, truth=%s", expectedCrc32, truthCrc32);
+ "Entries crc32 not match, file=%s, expected=%s, truth=%s", filePath, expectedCrc32, truthCrc32);

Verification

CheckpointFileTest (the module that already owns the checkpoint test) gains testCrcMismatchReportsTheFileAndTheExpectedCrc, which corrupts the stored crc32 on both the checkpoint and its .bak fallback and asserts the message names the path and the expected checksum. Before the change:

java.lang.AssertionError: Entries crc32 not match, file=823222925, truth=823222924

After the change, with JDK 8 (mvn -B -ntp -pl remoting -am test -Dtest='CheckpointFileTest' -DfailIfNoTests=false -Djacoco.skip=true):

Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
checkstyle:3.2.0:check: passed
spotbugs:4.8.6.8:check: BugInstance size is 0

The unit test is the verification for this one. The change was prepared with AI assistance and reviewed, tested and verified by me.

CheckpointFile.read builds the IOException for a crc32 mismatch with a "file=%s"
label but passes expectedCrc32 into it, so an operator who opens a corrupted
checkpoint reads e.g. "file=823222925" - a checksum where the path that failed to
load is expected - and the expected value itself is never named.

Pass the path that was read and label the expected checksum, and pin it with the
case that corrupts both the checkpoint and the .bak fallback read() falls back to.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 04:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by github-manager-bot

Summary

This PR fixes a bug in CheckpointFile.read() where the CRC32 mismatch error message was printing the expected CRC value in the file=%s placeholder instead of the actual file path. The fix correctly passes filePath as the first format argument and adds a labeled expected=%s field for the expected CRC value. A new unit test validates the corrected error message.

Assessment: ✅ Looks Good

Correctness:

  • The original bug is clear: String.format("file=%s, truth=%s", expectedCrc32, truthCrc32) was passing a long where a String (file path) was expected in the format string.
  • The fix String.format("file=%s, expected=%s, truth=%s", filePath, expectedCrc32, truthCrc32) correctly resolves the argument order and adds proper labeling.
  • The filePath parameter is available in scope (read(String filePath)), so no additional plumbing is needed.

Test Coverage:

  • testCrcMismatchReportsTheFileAndTheExpectedCrc is well-structured: it corrupts both the primary and .bak checkpoint files, triggers the read, and asserts the error message contains the file path, expected CRC, and truth label.
  • The test correctly uses System.lineSeparator() for cross-platform compatibility.

Minor Observations:

  1. The error message format change is backward-incompatible for any tooling that parses this specific error string. However, since this is a diagnostic message for operators (not a machine-readable protocol), this is acceptable.
  2. Consider whether filePath should be logged as an absolute path for easier debugging in production environments. Currently it depends on how the caller constructs the path.

Verdict

Clean, focused fix with proper test coverage. No blocking issues.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 49.72%. Comparing base (5d68880) to head (9cda1d6).

Files with missing lines Patch % Lines
...g/apache/rocketmq/common/utils/CheckpointFile.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11453      +/-   ##
=============================================
- Coverage      49.76%   49.72%   -0.05%     
+ Complexity     14377    14369       -8     
=============================================
  Files           1390     1390              
  Lines         103262   103262              
  Branches       13504    13504              
=============================================
- Hits           51392    51350      -42     
- Misses         45681    45713      +32     
- Partials        6189     6199      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RongtongJin
RongtongJin merged commit f338610 into apache:develop Oct 19, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] The checkpoint crc mismatch message prints a checksum where the file name belongs

5 participants