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

raftstore: clean callback when peer is destroyed #1683

Merged
merged 5 commits into from
Mar 17, 2017

Conversation

BusyJay
Copy link
Member

@BusyJay BusyJay commented Mar 16, 2017

Callback of read index isn't cleared when the peer is destroyed, which will lead to dead lock.

@siddontang @zhangjinpeng1987 @hhkbp2 PTAL

@siddontang
Copy link
Contributor

CI failed

Copy link
Contributor

@siddontang siddontang left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -380,3 +385,37 @@ fn test_server_lease_unsafe_during_leader_transfers() {
let mut cluster = new_node_cluster(0, count);
test_lease_unsafe_during_leader_transfers(&mut cluster);
}

#[test]
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a brief description of what this test case is for.

@hhkbp2
Copy link
Contributor

hhkbp2 commented Mar 17, 2017

Rest LGTM

for read in self.reads.drain(self.ready_cnt..) {
for (req, cb) in read.cmds {
for mut read in self.reads.drain(self.ready_cnt..) {
for (req, cb) in read.cmds.drain(..) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it just a refactoring behavior and have nothing to do with this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

When drop is implemented, it can be moved partially.

self.pending_reads.clear_uncommitted(&self.tag, term);
}
if ready.ss.is_some() {
let term = self.term();
Copy link
Member

Choose a reason for hiding this comment

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

Why not clear for leader before?

Copy link
Member Author

Choose a reason for hiding this comment

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

When the peer is not leader before, there will be no uncommitted in pending reads. Remove the check just make code more simple.

return true;
}
return false;
return match self.block {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some annotations in this file, it's hard for me to understand?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, but not related to this pr.

@zhangjinpeng87
Copy link
Member

LGTM

@BusyJay BusyJay merged commit dae4a17 into master Mar 17, 2017
@BusyJay BusyJay deleted the busyjay/notify-callback-when-destroyed branch March 17, 2017 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants