handle error in ProtoBufFile::load
- Dominant language
- C++
- Stars
- 4.2k
- Forks
- 923
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/baidu/braft/blob/e32b78a1f4973534aaa047dc2ead9167ec091b56/src/braft/protobuf_file.cpp#L87-L120
1. 117 行没有检查返回值
2. 如果执行到了112行, 且原因是实际文件长度比预期的短,返回了 -1。但读文件是成功的,errno 不会被更新。加载 log_meta时,如果发生了上述问题,且原来的 errno 正好是 ENOENT,后续逻辑会认为日志是空的,直接把 log 删光。
https://github.com/baidu/braft/blob/e32b78a1f4973534aaa047dc2ead9167ec091b56/src/braft/log.cpp#L1155-L1175
Contributor guide
No contributing guide indexed for this repository
Research direction
Read src/braft/protobuf_file.cpp around lines 87-120, then trace its use in src/braft/log.cpp around lines 1155-1175. Check how short reads, return values, and errno are propagated during log_meta loading. Done means failed reads cannot be treated as an empty log and all relevant error returns are handled consistently.
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
- Mostly clear
- Newbie friendliness
- 40/100