Skip to content

Commit

Permalink
Merge pull request #922 from graydon/bug-869-state-machine-publish-as…
Browse files Browse the repository at this point in the history
…sert-again

Make retry-states idempotent in state machines, fix #869.

Reviewed-by: jedmccaleb
  • Loading branch information
latobarita committed Nov 17, 2015
2 parents 9cafcfb + ca89c5d commit c9bfa9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/history/CatchupStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,13 @@ CatchupStateMachine::enterRetryingState(uint64_t nseconds)
{
assert(mState == CATCHUP_BEGIN || mState == CATCHUP_ANCHORED ||
mState == CATCHUP_FETCHING || mState == CATCHUP_APPLYING ||
mState == CATCHUP_VERIFYING);
mState == CATCHUP_VERIFYING || mState == CATCHUP_RETRYING);

if (mState == CATCHUP_RETRYING)
{
return;
}

bool anchored = mState >= CATCHUP_ANCHORED;
bool verifying = mState >= CATCHUP_VERIFYING;
mState = CATCHUP_RETRYING;
Expand Down
8 changes: 7 additions & 1 deletion src/history/PublishStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ void
ArchivePublisher::enterRetryingState()
{
assert(mState == PUBLISH_BEGIN || mState == PUBLISH_SENDING ||
mState == PUBLISH_COMMITTING);
mState == PUBLISH_COMMITTING || mState == PUBLISH_RETRYING);

if (mState == PUBLISH_RETRYING)
{
return;
}

mState = PUBLISH_RETRYING;
mRetryTimer.expires_from_now(std::chrono::seconds(2));
std::weak_ptr<ArchivePublisher> weak(shared_from_this());
Expand Down

0 comments on commit c9bfa9f

Please sign in to comment.