-
Notifications
You must be signed in to change notification settings - Fork 2
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
implement fast-accept handler #182
Conversation
let mut inst = match self.storage.get_instance(iid)? { | ||
Some(_) => return Err(Error::Existed {}), | ||
None => self._empty_instance(Some(iid)), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对于COMMITTED,ACCEPTED,EXECUTED的instance,是不需要走下面的流程的吧,recover的时候可能会遇到
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COMMITTED,ACCEPTED,EXECUTED的instance,貌似就不应该发送fast-accept请求
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
两个replica先后恢复一个inst的时候呢,其中一个恢复成功了,两位一个恢复的时候就会遇到这样的情况
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
恢复的时候不会用到 fast_accept 吧..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
恩...恢复不用fast.
None => self._empty_instance(Some(iid)), | ||
}; | ||
|
||
inst.ballot = Some(ballot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要判断req.ballot < inst.ballot吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
req.ballot > inst.ballot吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一样的啊,看你怎么处理了,我得意思是req.ballot < inst.ballot直接返回
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不明白这块为啥要判断 ballot,求讲。我理解 fast_accept 是无论怎样都接收请求,直接把 req.ballot 填在 inst 就好啊...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果在恢复中, ballot会大于0. 阻止leader继续运行. 否则recover进程和leader可能commit不同的值.
let (ballot, iid) = self._check_req_common(&req.cmn)?; | ||
|
||
let mut inst = match self.storage.get_instance(iid)? { | ||
Some(_) => return Err(Error::Existed {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
按照paxos的尿性, 如果遇到重发的消息应该处理下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可, 处理下重复消息
for x in self.storage.get_instance_iter(start_iid, true) { | ||
if x.deps[la] < iid && (inst.conflict(&x) || x.committed) { | ||
if let Some(x_iid) = x.instance_id { | ||
let lx = x_iid.leader_of() as usize; | ||
|
||
if x_iid > inst.deps[lx] { | ||
inst.deps[lx] = x_iid; | ||
deps_committed[lx] = x.committed; | ||
} else if x_iid == inst.deps[lx] { | ||
deps_committed[lx] = deps_committed[lx] || x.committed; | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.c
↙ |
d d |
↓ ↓↘ ↙
a a→b c
x y z x y z x y z
----- ----- -----
R0 R1 R2
这一种逻辑下,d,c依次发送到R1,由于d->a,间接c->a,a发送到R1的时候是不能依赖c的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
逻辑是这样的, a只依赖z
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a.deps=[x, b, z], 测试用例就是这个例子
let start_iid = (*rid, 0).into(); | ||
|
||
for x in self.storage.get_instance_iter(start_iid, true) { | ||
if x.deps[la] < iid && (inst.conflict(&x) || x.committed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不能这样读取deps,deps是Vec,你得find,replicaid可能是不连续的,或者非常大
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
除了读 inst.deps 的问题,没看出别的..
None => self._empty_instance(Some(iid)), | ||
}; | ||
|
||
inst.ballot = Some(ballot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不明白这块为啥要判断 ballot,求讲。我理解 fast_accept 是无论怎样都接收请求,直接把 req.ballot 填在 inst 就好啊...
let mut inst = match self.storage.get_instance(iid)? { | ||
Some(_) => return Err(Error::Existed {}), | ||
None => self._empty_instance(Some(iid)), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
恢复的时候不会用到 fast_accept 吧..
e19f7f1
to
4f4c5aa
Compare
let mut inst = match self.storage.get_instance(iid)? { | ||
Some(v) => { | ||
if v.ballot.is_none() || v.ballot.unwrap().num != 0 { | ||
return Err(Error::Existed {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是ballot大的话下面通过返回把last_ballot返回给调用者来处理,不作为错误了.
4f4c5aa
to
5fdb8de
Compare
Description
implement fast-accept handler