baidu / baidu/braft

Unittest NodeTest.LeaderFailWithWitness is not stable.

Open
#445 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
4.2k
Forks
923
PR merge metrics
No merged PRs in 30d

Description

NodeTest.LeaderFailWithWitness 测试用例:
https://github.com/baidu/braft/blob/b37c610039aa34d6df2e5bda12f830003561b08b/test/test_node.cpp#L462-L477

这段逻辑应该是 2 个 Replica 和一个 Witness 节点,当选出 leader 后,杀死leader,并用 follower 进行日志提交。
但是在这个 for 循环之前,有可能该 follower 已经成为 leader 了,导致 followers 的个数只有 1 个,使用 nodes[1] 会越界。

image

@lintanghui

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with NodeTest.LeaderFailWithWitness in test/test_node.cpp around lines 462-477. Reproduce the unstable election scenario where the follower may already become leader before the loop, then trace how followers and nodes[1] are selected. Done means the test remains valid when leadership changes and no longer risks an out-of-bounds access.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
distributed-systems, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.