You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "yuluo-yx (via GitHub)" <gi...@apache.org> on 2026/08/08 10:08:28 UTC
[I] [Bug] CheckpointFile cannot persist empty checkpoints [rocketmq]
yuluo-yx opened a new issue, #10863:
URL: https://github.com/apache/rocketmq/issues/10863
## 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] CheckpointFile cannot persist empty checkpoints [rocketmq]
Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #10863:
URL: https://github.com/apache/rocketmq/issues/10863#issuecomment-5225829212
**Issue Evaluation**
Category: `bug` | Status: **Confirmed**
The reported issue has been verified against the current codebase (commit `fd0c959`).
**Root Cause:** `CheckpointFile.write()` returns immediately when the entry list is empty (line 74: `if (entries.isEmpty()) { return; }`), never persisting the empty state. Additionally, `read()` falls back to the backup file when the primary returns an empty list (`CollectionUtils.isEmpty(result)`), so a valid empty primary can be replaced by stale backup data.
**Impact:** Components relying on checkpoint persistence (e.g., consumer offset tracking) may recover stale state after a restart if the last checkpoint was intended to be empty.
**Severity:** medium — data correctness issue in edge case (empty checkpoint scenarios)
**Suggested Fix:**
- `write()`: Persist empty checkpoints by writing `0\n<crc32>\n` to both primary and backup files.
- `read()`: Only fall back to backup when the primary file is missing or unreadable, not when it contains a valid empty checkpoint.
An automated fix proposal will be generated. Reply `/approve` to proceed with PR generation.
---
*Automated evaluation by RockteMQ-AI*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] CheckpointFile cannot persist empty checkpoints [rocketmq]
Posted by "BILLYisavailable (via GitHub) via commits" <co...@rocketmq.apache.org>.
BILLYisavailable commented on issue #10863:
URL: https://github.com/apache/rocketmq/issues/10863#issuecomment-7221921378
Confirmed this still reproduces on develop 19352a24679337276e041f67307c6d284dd48de9. In addition to the CheckpointFile-level case, I exercised the EpochFileCache caller: start with three entries, call truncateSuffixByEpoch(1), verify the in-memory size is zero, then initialize a new EpochFileCache from the same path. The original implementation reloads three entries (`expected 0 but was 3`).
#11642 fixes the empty write and valid-empty-primary handling with regression coverage for that caller. The six CheckpointFile tests and eight EpochFileCache tests pass with the change. The PR credits the earlier closed attempts #10868 and #11032; malformed numeric headers are left to the separate #11463 change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org