镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[ISSUE #11460] Recover checkpoints with malformed numeric headers - #11463

Open
hickey-ai wants to merge 2 commits into
apache:developfrom
hickey-ai:codex/rocketmq-checkpoint-header-20261020
Open

hickey-ai wants to merge 2 commits into
apache:developfrom
hickey-ai:codex/rocketmq-checkpoint-header-20261020

Conversation

@hickey-ai

Copy link
Copy Markdown

Which Issue(s) This PR Fixes

Fixes #11460

Brief Description

Convert NumberFormatException from the two numeric checkpoint header fields to IOException with the file path and original cause. This lets the existing .bak recovery work for empty, truncated or malformed headers. The catch is limited to header parsing; serializer exceptions, empty-state behavior and normal primary precedence are not changed.

This is distinct from #11032, which handles persisting/reading empty checkpoint state.

How Did You Test This Change?

  • The original implementation reproduced an unchecked NumberFormatException in the native common test. Surefire stopped after the first failure (2 reported: 1 error, 1 skipped); all six new methods were not claimed executed before the fix.
  • Independent Java 8/Maven 3.6.3 run: mvn -B -pl remoting -am -Dtest=CheckpointFileHeaderTest,CheckpointFileTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false test.
  • All 9 tests passed (6 new common header tests and 3 existing remoting checkpoint tests), 0 failures/errors/skips. Checkstyle and SpotBugs passed.
  • Full published Git tree equals the tested local commit tree.

No live broker or HA failover test is claimed.

AI assistance: OpenAI Codex was used for investigation, implementation and tests; commits include tooling provenance.

Translate only numeric header parsing failures to IOException so the existing backup recovery path can run.

Generated-by: OpenAI Codex
…covery

Cover truncated/invalid count and CRC headers, bad backups, integrity mismatch controls, and valid-primary precedence.

Generated-by: OpenAI Codex

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

LGTM. The fix improves error handling for corrupted checkpoint headers.

Summary

Wrapped Integer.parseInt() calls in CheckpointFile.read() to convert NumberFormatException to IOException with context.

Analysis

Checkpoint files have a two-line header (expected line count + CRC). If these lines are corrupted or truncated, the original code would throw a raw NumberFormatException without context. The fix converts this to an IOException with the file path included, which allows the checkpoint recovery mechanism to gracefully fall back to the backup file.

The test suite comprehensively covers malformed headers (truncated, non-numeric count, non-numeric CRC), fallback behavior, and valid primary precedence. All edge cases are well-covered.


Automated review by github-manager-bot

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.79%. Comparing base (57c2dc0) to head (d50e927).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11463      +/-   ##
=============================================
- Coverage      49.79%   49.79%   -0.01%     
+ Complexity     14387    14380       -7     
=============================================
  Files           1390     1390              
  Lines         103264   103267       +3     
  Branches       13504    13504              
=============================================
- Hits           51419    51417       -2     
+ Misses         45657    45647      -10     
- Partials        6188     6203      +15     

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

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] CheckpointFile skips valid backup recovery when the primary numeric header is malformed

3 participants