Skip to content

[Bug] CheckpointFile cannot persist empty checkpoints #10863

Description

@yuluo-yx

Runtime platform environment

macOS; reproduced with a temporary checkpoint file in the common module.

RocketMQ version

Branch: develop
Git commit: fd0c95920e0deac96ce2ae27442747cc5e65e930

JDK Version

Eclipse Temurin 17.0.19+10

Describe the Bug

CheckpointFile.write returns immediately for an empty entry list, leaving old entries on disk. In addition, read() treats a valid empty primary file as a reason to load the backup, so stale backup entries can be restored instead of an intentionally empty state.

Steps to Reproduce

  1. Write a checkpoint containing entries.
  2. Write an empty entry list to the same CheckpointFile.
  3. Read the checkpoint.
  4. Observe that old entries remain. A valid empty primary file also causes read() to return entries from its older backup.

What Did You Expect to See?

An empty list should be persisted as a valid zero-entry checkpoint, and reading that valid primary should return an empty list. Backup fallback should only occur when the primary is missing or invalid.

What Did You See Instead?

Empty writes are ignored, and a valid empty primary can be replaced in memory by stale backup content.

Additional Context

The existing count and CRC format can represent an empty checkpoint without a format change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions