[Bug] CheckpointFile skips valid backup recovery when the primary numeric header is malformed
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start by reading CheckpointFile.read(String) and the public read() recovery path; also inspect EpochFileCache.initCacheFromFile and the existing remoting CheckpointFileTest tests. Reproduce with a malformed primary numeric header and a valid .bak, then verify recovery, failure cause and path when both headers are invalid, and regression behavior for valid primaries and CRC/count mismatches. PR #11032 is unrelated; open PR #11063 already proposes this fix.
索引モデルが issue の本文から書いたものです。
説明
Before Creating the Bug Report
-
I found a bug, not just asking a question, which should be created in GitHub Discussions.
-
I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.
-
I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
Runtime platform environment
Windows 11; local checkpoint files and native common/remoting module tests. No live broker or HA failover claim.
RocketMQ version
develop, revision 5.5.1, commit 57c2dc04f78cc7e73e6b8c9436ee0fff0d0f46c3.
JDK Version
OpenJDK 1.8.0_302 (GraalVM CE 21.2.0), Maven 3.6.3.
Describe the Bug
CheckpointFile.read(String) parses the entry count and CRC with Integer.parseInt. An empty, truncated or nonnumeric header throws NumberFormatException, while public read() only catches IOException to recover from .bak. A valid backup is therefore ignored. EpochFileCache.initCacheFromFile also only catches IOException.
Steps to Reproduce
- Create a CheckpointFile whose serializer writes and reads the entry string unchanged.
- Write Collections.singletonList("saved") and copy the checkpoint file to checkpoint.getBackFilePath().
- Replace the primary file with "invalid\n0\nvalue\n" (or an empty file).
- Call checkpoint.read().
The valid backup can be read on its own; the malformed primary prevents reaching it.
What Did You Expect to See?
Malformed numeric headers enter the existing IOException recovery path and the valid backup is returned. If the backup header is also invalid, the final failure is IOException with the failing path and NumberFormatException as its cause.
What Did You See Instead?
An unchecked NumberFormatException escapes from parsing the primary header instead of loading the valid backup.
Additional Context
The proposed fix only wraps the two numeric header parses; serializer exceptions are not swallowed. Existing valid-primary precedence and CRC/count mismatch behavior are regression controls. Six new header tests plus the three existing remoting CheckpointFileTest tests pass on the independent patch (9 native tests, 0 failures/errors/skips). Baseline native Surefire reproduced the NumberFormatException and stopped after the first failure; not all six new methods ran before the fix. Checkstyle/SpotBugs pass.
PR #11032 concerns empty checkpoint state and does not handle malformed numeric headers. Issue/PR/discussion searches did not identify this header-recovery fix.
AI assistance: OpenAI Codex was used for investigation, implementation and tests.
- 主要言語
- Java
- スター
- 22.7k
- フォーク
- 12k
- 平均マージ
- 4日 20時間
- マージ済み PR(30日)
- 11
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/rocketmq のほかの issue
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configuration対応中かも @amalsaidov が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
CompressionType.of fails under the Turkish locale対応中かも @sharanggupta が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
[rocketmq-client-python] TransactionMQProducer allocates an unused producer during initializationオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
[Bug] notifyMasterOnline aborts the long-polling wake-up with a NullPointerException when an arrival drains a bucket first対応中かも @iloveeyjafjalla が 29 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/rocketmq#11441 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Enhancement] FilterFactory duplicate-registration and unregister semantics lack tests対応中かも @chennaji9 が 34 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
apache/rocketmq#11340 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
apache/rocketmq の issue をすべて見る
似ている issue
-
bug emitter:client:csharp
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/typespec#12572 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
area/ai area/backend component/zeebe kind/task
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
spAnser/reacharound#38 ·