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

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

2 participants