Skip to content

[ISSUE #10863] Persist empty checkpoints - #10868

Open
yuluo-yx wants to merge 1 commit into
apache:developfrom
yuluo-yx:0808-yuluo/fix-20
Open

[ISSUE #10863] Persist empty checkpoints#10868
yuluo-yx wants to merge 1 commit into
apache:developfrom
yuluo-yx:0808-yuluo/fix-20

Conversation

@yuluo-yx

@yuluo-yx yuluo-yx commented Aug 8, 2026

Copy link
Copy Markdown
Member

Which Issue(s) This PR Fixes

Brief Description

CheckpointFile.write now persists an empty list as a valid zero-entry checkpoint instead of retaining old data. read() also trusts a valid empty primary and only falls back to the backup when the primary is missing or cannot be read.

Regression tests cover clearing a populated checkpoint and recovering from a corrupted primary through the backup.

How Did You Test This Change?

  • mise exec java@temurin-17.0.19+10 -- mvn -pl common -am -DskipITs -Dtest=CheckpointFileTest -Dsurefire.failIfNoSpecifiedTests=false -Dspotbugs.skip=true test
  • Result: BUILD SUCCESS; 2 tests, 0 failures, 0 errors, 0 skipped.
  • Scope check: 2 files, 81 changed lines.

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

Summary

Fixes a correctness issue where CheckpointFile.write silently discarded empty checkpoint lists, causing stale data to persist. The read() logic is also corrected to trust a valid empty primary file instead of always falling back to backup.

Analysis

  • Correctness ✅ — Removing the early return on empty input allows legitimate empty checkpoints to be persisted. The new read() logic correctly checks file existence rather than result emptiness, which properly distinguishes "file exists with 0 entries" from "file missing/unreadable".
  • Tests ✅ — Two well-targeted regression tests: one verifies clearing a populated checkpoint, the other verifies backup fallback on corrupted primary.
  • Compatibility ✅ — Behavior change is intentional and fixes a data integrity issue. No API changes.

LGTM.


Automated review by github-manager-bot

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.35%. Comparing base (fd0c959) to head (c2d4867).

Files with missing lines Patch % Lines
...g/apache/rocketmq/common/utils/CheckpointFile.java 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10868      +/-   ##
=============================================
- Coverage      48.39%   48.35%   -0.05%     
+ Complexity     13562    13543      -19     
=============================================
  Files           1380     1380              
  Lines         101165   101162       -3     
  Branches       13127    13126       -1     
=============================================
- Hits           48962    48917      -45     
- Misses         46233    46251      +18     
- Partials        5970     5994      +24     

☔ 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 cannot persist empty checkpoints

3 participants