-
Notifications
You must be signed in to change notification settings - Fork 886
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
疑似bug确认 #173
Comments
另外请问什么情况下会导致iter_impl出现error |
我尝试回答下:
if (iter_impl.has_error()) {
set_error(iter_impl.error());
iter_impl.run_the_rest_closure_with_error();
}
void FSMCaller::do_committed(int64_t committed_index) {
if (!_error.status().ok()) {
return;
} FSMCaller 的 int64_t last_applied_index = _last_applied_index.load(
butil::memory_order_relaxed);
.....
_log_manager->set_applied_id(last_applied_id); 因此并不存在数据安全问题。
用户在 apply task 到状态机的时候可能遇到不可控的异常(比如网络或者文件磁盘沾满等 IO 问题),这种时候用户可以主动终止状态机继续执行,调用 |
感谢回复。 bool FSMCaller::pass_by_status(Closure* done) {
brpc::ClosureGuard done_guard(done);
if (!_error.status().ok()) {
if (done) {
done->status().set_error(
EINVAL, "FSMCaller is in bad status=`%s'",
_error.status().error_cstr());
}
return false;
}
done_guard.release();
return true;
} 但是如果从语义理解上,在error情况下,committed_index并不一定等于last_index,那意味着committed_index的entry的term也不一定等于last_index对应entry的term;而 _last_applied_index和_last_applied_term我理解是对应同一个entry的,如果是这样的话,这里用_last_applied_index设为last_index是否更加合适。 const int64_t last_index = iter_impl.index() - 1;
const int64_t last_term = _log_manager->get_term(last_index);
LogId last_applied_id(last_index, last_term);
_last_applied_index.store(committed_index, butil::memory_order_release);
_last_applied_term = last_term;
_log_manager->set_applied_id(last_applied_id); |
@promoon 是设置为 last_index,我看错了,注意这行: LogId last_applied_id(last_index, last_term); 取的是当前 iterator 的 index,set_error_and_rollback 会重新计算 current_index 的。 |
@killme2008 _last_applied_index.store(committed_index, butil::memory_order_release); |
@promoon 了解了,error 情况下,用 last_index 确实更合适,虽然不影响正确性,可以等官方来回答下。 |
fsm_caller.cpp 306行,
_last_applied_index.store(committed_index, butil::memory_order_release);
这一步为什么设置_last_applied_index为committed_index,而不是last_index。
正常情况下两者应该都是相等的,但是如果iter_impl出现error的情况下呢?
The text was updated successfully, but these errors were encountered: