Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
KEP-901: Request forwarded to dead primary causes endless viewchange …
Browse files Browse the repository at this point in the history
…loop (#198)
  • Loading branch information
paularchard committed Dec 14, 2018
1 parent 299d8dc commit 53a9fa0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pbft/pbft_failure_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ pbft_failure_detector::handle_timeout(boost::system::error_code /*ec*/)
if (this->completed_requests.count(this->ordered_requests.front()) == 0)
{
LOG(error) << "Failure detector detected unexecuted request " << this->ordered_requests.front() << '\n';
this->start_timer();
this->ordered_requests.pop_front();
if (this->ordered_requests.size() > 0)
{
this->start_timer();
}

this->io_context->post(std::bind(this->failure_handler));
return;
}
Expand Down
4 changes: 2 additions & 2 deletions pbft/test/pbft_failure_detector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ namespace
ASSERT_TRUE(this->failure_detected);
}

TEST_F(pbft_failure_detector_test, timeout_restarts_timer)
TEST_F(pbft_failure_detector_test, timeout_doesnt_restart_timer)
{
EXPECT_CALL(*(this->request_timer), expires_from_now(_)).Times(Exactly(2));
EXPECT_CALL(*(this->request_timer), expires_from_now(_)).Times(Exactly(1));
this->build_failure_detector();

this->failure_detector->request_seen(req_a);
Expand Down

0 comments on commit 53a9fa0

Please sign in to comment.