[Bug] RaftEngineReadIndexTest fails now and then with UnfinishedStubbingException: the alive-peers refresher can call the mocked raft node while a test stubs it
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #3385 来自 @Mihir-Rabari —— 已合并
评估
调研方向
Read RaftEngineReadIndexTest.java around answerShutdown and testStoppedReadServiceClosureThatRunsFirstFailsAsNotLeader, then inspect RaftEngine.startAlivePeersRefresher and its listAlivePeers call. Reproduce with the stated Maven command and determine whether the refresher can call the mock during stubbing. The linked pull request #3385 is already open; check its status and whether it resolves the intermittent failure.
由索引模型根据 Issue 内容生成。
描述
Bug Type (问题类型)
others (please edit later)
Before submit
- I have confirmed and searched that there are no similar problems in the historical issue and documents
Environment (环境信息)
- Server Version: PD tests,
hg-pd-testpd-core-testprofile (PDCoreSuiteTest). Seen on the branch of #3376 at171760d25, which does not changeRaftEngineReadIndexTestor the alive-peers refresher ofRaftEngine; both are as onmaster86c05ef9c(the test from #3368, the refresher from #3185) - Backend: none (unit suite)
- OS: Linux, 8 cores, JDK 17
- Data Size: N/A
Expected & Actual behavior (期望与实际表现)
RaftEngineReadIndexTest.testStoppedReadServiceClosureThatRunsFirstFailsAsNotLeader should pass every run. It failed once in three runs of the same commit on 2026-10-20, with Mockito's unfinished-stubbing error while the test stubs readIndex:
[ERROR] org.apache.hugegraph.pd.raft.RaftEngineReadIndexTest.testStoppedReadServiceClosureThatRunsFirstFailsAsNotLeader -- Time elapsed: 0.012 s <<< ERROR!
org.mockito.exceptions.misusing.UnfinishedStubbingException:
Unfinished stubbing detected here:
-> at org.apache.hugegraph.pd.raft.RaftEngineReadIndexTest.answerShutdown(RaftEngineReadIndexTest.java:377)
at org.apache.hugegraph.pd.raft.RaftEngineReadIndexTest.answerShutdown(RaftEngineReadIndexTest.java:382)
at org.apache.hugegraph.pd.raft.RaftEngineReadIndexTest.testStoppedReadServiceClosureThatRunsFirstFailsAsNotLeader(RaftEngineReadIndexTest.java:367)
The runs, all mvn -B -ntp test -pl hugegraph-pd/hg-pd-test -am -P pd-core-test on 171760d25:
| Host | pd-core (run/failures/errors/skipped) |
|---|---|
| 8 cores, JDK 17 | 227/0/1/2 (this error) |
| same host, again | 227/0/0/2 |
| 12 cores, JDK 17 | 227/0/0/2 |
Likely cause, not proven: the test swaps a Mockito mock into the RaftEngine singleton (Whitebox.setInternalState(..., "raftNode", mockNode)) and stubs it, while the engine's pd-raft-alive-peers refresher thread (startAlivePeersRefresher, every ALIVE_PEERS_REFRESH_MS) calls node.listAlivePeers() on whatever node the singleton holds whenever its state machine reports leader. An earlier suite test can leave the singleton started and leading. A call on the mock from that thread while doAnswer(...).when(mockNode).readIndex(...) is in progress is the case Mockito reports as unfinished stubbing.
A fix could stop the refresher for these tests (or give the refresher a node snapshot taken under the same lock the tests use), or stub listAlivePeers on the mock before it is installed.
Vertex/Edge example (问题点 / 边数据举例)
N/A
Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
N/A
- 主要语言
- Java
- 星标
- 3.2k
- 派生
- 640
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 98
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/hugegraph 的其他 Issue
-
[Bug] PD task REST: balanceLeaders throws a bare HTTP 500 during the balance-shard window, and task responses cannot be told apart from a no-op or a follower answer可能已有人在做 @pallavithegod 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
apache/hugegraph#3231 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
[Bug] PD TTL cleanup deletes the marker-shaped name instead of the expired key, so expired values stay in the store until read可能已有人在做 @bitflicker64 于 2 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
[Task] Establish systematic performance baselines and optimization tracking可能已有人在做 @contrueCT 于 6 天前认领。 未关闭help wanted improvement rust
难度 5/5 一周以上 新手友好度 12/100
apache/hugegraph#3346 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 67/100
Vakore/ZappierGames#184 ·
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
lugassawan/swe-workbench#823 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
cassiancc/Raspberry-Core#69 ·
-
难度 2/5 1-3 小时 新手友好度 85/100
IronCoreLabs/ironcore-alloy#351 ·
-
难度 2/5 1-3 小时 新手友好度 79/100
checkstyle/checkstyle#22145 ·
维护者通常 1 天内回复