Skip to content
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

Merged
merged 2 commits into from
Mar 18, 2020
Merged

implement fast-accept handler #182

merged 2 commits into from
Mar 18, 2020

Conversation

pengsven
Copy link

Description

implement fast-accept handler

  • Self-review: I have performed a self-review of my own code
  • Comment: I have commented my code, particularly in hard-to-understand areas
  • Doc: I have made corresponding changes to the documentation
  • No-warnings: My changes generate no new warnings
  • Add-test: I have added tests that prove my fix is effective or that my feature works
  • Pass: New and existing unit tests pass locally with my changes

let mut inst = match self.storage.get_instance(iid)? {
Some(_) => return Err(Error::Existed {}),
None => self._empty_instance(Some(iid)),
};

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的时候可能会遇到

Copy link
Author

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请求

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

两个replica先后恢复一个inst的时候呢,其中一个恢复成功了,两位一个恢复的时候就会遇到这样的情况

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恢复的时候不会用到 fast_accept 吧..

Copy link
Member

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里需要判断req.ballot < inst.ballot吧

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

req.ballot > inst.ballot吧

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一样的啊,看你怎么处理了,我得意思是req.ballot < inst.ballot直接返回

Copy link
Member

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 就好啊...

Copy link
Member

@drmingdrmer drmingdrmer Mar 13, 2020

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不同的值.

components/epaxos/src/qpaxos/mod.rs Outdated Show resolved Hide resolved
let (ballot, iid) = self._check_req_common(&req.cmn)?;

let mut inst = match self.storage.get_instance(iid)? {
Some(_) => return Err(Error::Existed {}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照paxos的尿性, 如果遇到重发的消息应该处理下

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可, 处理下重复消息

components/epaxos/src/replica/replica.rs Show resolved Hide resolved
Comment on lines 130 to 163
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;
}
}
}
}

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的

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

逻辑是这样的, a只依赖z

Copy link
Author

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) {

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可能是不连续的,或者非常大

Copy link
Member

@wenbobuaa wenbobuaa left a 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);
Copy link
Member

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)),
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恢复的时候不会用到 fast_accept 吧..

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 {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果是ballot大的话下面通过返回把last_ballot返回给调用者来处理,不作为错误了.

@pengsven pengsven merged commit 5fdb8de into master Mar 18, 2020
@pengsven pengsven deleted the shuwen.fast-accept branch March 18, 2020 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants