Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unittest NodeTest.LeaderFailWithWitness is not stable. #445

Open
ehds opened this issue Mar 26, 2024 · 1 comment
Open

Unittest NodeTest.LeaderFailWithWitness is not stable. #445

ehds opened this issue Mar 26, 2024 · 1 comment

Comments

@ehds
Copy link
Contributor

ehds commented Mar 26, 2024

NodeTest.LeaderFailWithWitness 测试用例:

braft/test/test_node.cpp

Lines 462 to 477 in b37c610

// apply something when follower
std::vector<braft::Node*> nodes;
cluster.followers(&nodes);
cond.reset(10);
for (int i = 0; i < 10; i++) {
butil::IOBuf data;
char data_buf[128];
snprintf(data_buf, sizeof(data_buf), "follower apply: %d", i + 1);
data.append(data_buf);
braft::Task task;
task.data = &data;
task.done = NEW_APPLYCLOSURE(&cond, -1);
// node 0 is witness;
nodes[1]->apply(task);
}
cond.wait();

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

image

@lintanghui

@JayiceZ
Copy link

JayiceZ commented May 31, 2024

Thanks for your report! We should temporarily disable followers' election before stop the leader to ensure that the raft group will be no-leader state for a period of time deterministically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants