执行truncate suffix的时候没有将last_segment从 _segment中移除
- Dominant language
- C++
- Stars
- 4.2k
- Forks
- 923
- PR merge metrics
- No merged PRs in 30d
Description
当前raftlog 文件列表 包含
`log_0-10, log_11_20, log_21_30, log_inprogress_31`
此时执行truncate_suffix(15). 执行完成后文件列表变为
` log_0_10, log_inprogress_11`
此时执行SegmentLogStorage->segments() 会返回两个 log_0_10, 和log_inprogress两个文件。正常情况下 应该将 log_inprogress_11从_segments 里移除
https://github.com/baidu/braft/blob/master/src/braft/log.cpp#L930 这里swap的时候还需要 _segments.erase(last_segment->first_index());
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/braft/log.cpp around line 930 and inspect the swap during truncate_suffix(15). Reproduce the listed segment layout, then verify that SegmentLogStorage->segments() no longer includes log_inprogress_11 after truncation. Done means the stale last_segment entry is removed from _segments while the remaining files match the expected list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100