Fix DecisionsInView reset to zero during same-height sync#663
Open
ivan-atme wants to merge 1 commit intohyperledger-labs:mainfrom
Open
Fix DecisionsInView reset to zero during same-height sync#663ivan-atme wants to merge 1 commit intohyperledger-labs:mainfrom
ivan-atme wants to merge 1 commit intohyperledger-labs:mainfrom
Conversation
When sync() is called but the synchronizer returns the same block height
as the controller ("already at target height"), newDecisionsInView stays
at its zero-initialized value because the update at line 641 is guarded
by `latestDecisionSeq > controllerSequence`, which is false when equal.
This zero is passed to changeView(), resetting DecisionsInView from its
correct value (e.g. 9578) to 0. The next proposal from the leader carries
the correct DecisionsInView, fails validation at view.go:577, and is
rejected as "bad proposal", triggering a recovery sync loop that costs
~10 seconds per cycle and can cause orderers to fall permanently behind.
Fix: decouple the DecisionsInView update from the checkpoint update by
moving it to a separate `if latestDecisionMetadata != nil` block, so
decisions are always derived from sync response metadata regardless of
whether the sequence advanced.
Signed-off-by: ivan-atme <ivan.laishevskiy@atme.com>
Contributor
|
Thank you for discovering this bug and providing a fix. |
Author
|
@HagarMeir I am attaching orderers' logs: org0-orderer-1-stuck.zip . Sorry, logs are quite long (05:59:38-06:02:31). There is a reason for this (see below). Additional context about the problem:
Timeline
ConclusionThus, currently fixed issue was not the only cause which triggered the org0-orderer-1 got stuck. I found few more issues that together make orderer being stuck. I described two more changes I offer in RFC draft: https://gist.github.com/ivan-atme/73c430c9a530985546af6f34139cddb6#file-rfc-smartbft-controller-bugs-upstream-md Please let me know if there's anything I can do to make the review easier. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When sync() is called but the synchronizer returns the same block height as the controller ("already at target height"), newDecisionsInView stays at its zero-initialized value because the update at line 641 is guarded by
latestDecisionSeq > controllerSequence, which is false when equal.This zero is passed to changeView(), resetting DecisionsInView from its correct value (e.g. 9578) to 0. The next proposal from the leader carries the correct DecisionsInView, fails validation at view.go:577, and is rejected as "bad proposal", triggering a recovery sync loop that costs ~10 seconds per cycle and can cause Hyperledger Fabric orderers to fall permanently behind.
Fix: decouple the DecisionsInView update from the checkpoint update by moving it to a separate
if latestDecisionMetadata != nilblock, so decisions are always derived from sync response metadata regardless of whether the sequence advanced.