baidu / baidu/braft

发生切换时 leader 在执行自己 apply 的值时也可能拿到空的 callback

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

Description

仅记录供其它开发者参考,不一定需要修复。

发生顺序如下:
状态机 on_leader_start, term = t1
(中间经过一段时间正常运行)
写 apply, expected_term = t1, value = xxx,得到错误:leader stepped down
状态机 on_apply, index = x1, term = t1, value = xxx, done = nullptr (状态机记录了 on_leader_start 时的term,可以发现这种极端情况)
状态机 on_leader_stop
后续 apply 时均会报错 is not leader

结论:
leader状态机不能假设自己apply的值一定会携带自己传入的done,即使满足如下条件:
1. 在自己任期
2. term相符
3. 没有调用 on_leader_stop

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the state-machine entry points named in the report: on_leader_start, apply, on_apply, and on_leader_stop. Trace the term and callback state through the reported leader step-down sequence, then determine the expected behavior when on_apply receives done = nullptr; the issue is marked as a reference report rather than a defined fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.