Repository navigation
fix(fabric): keep the error type when collecting an endorsement fails - #2585
mbrandenburger merged 3 commits into
Conversation
|
Hey @SaidAltury-ibm 👋 thanks for the PR! This comment updates automatically as you push changes -- think of it as your PR's live scoreboard! PR Checks✅ DCO Sign-off -- All commits have valid sign-offs. Nice work! ❌ GPG Signature -- Heads up! The following commits don't have a verified GPG signature:
You'll need to sign your commits with GPG (e.g. ✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing! ✅ Issue Link -- Linked to #2557 (assigned to you). ⏳ All checks must pass before this PR can be reviewed. You've got this! |
mbrandenburger
left a comment
There was a problem hiding this comment.
Thank you @SaidAltury-ibm for working on this. Please see my comments below.
|
This pull request is merged. |
mbrandenburger
left a comment
There was a problem hiding this comment.
Thank you @SaidAltury-ibm
An application that spreads its endorsements over several endorser nodes needs to tell an endorser that is unavailable from any other failure. The collect-endorsements view lost that information: a rejection reply became a plain error with the payload as text, and a closed session and the one-minute timeout wrapped nothing. A rejection now returns session.RejectionError's error, which wraps session.ErrRejected and the reason's sentinel, such as session.ErrDraining. A closed session wraps comm.ErrSessionClosed, and the timeout wraps context.DeadlineExceeded. The godoc of NewCollectEndorsementsView and the Fabric SDK docs list the errors a caller can match. Fixes hyperledger-labs#2557 Signed-off-by: Said Altury <Said.Altury@ibm.com>
…t fails Signed-off-by: Said Altury <Said.Altury@ibm.com>
…t fails Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
0283f78 to
1d7d6c1
Compare
Summary
An application that spreads its endorsements over several endorser nodes needs to tell an endorser that is unavailable (draining, busy, closed, too slow) from any other failure, so that it tries the next endorser only in the first case.
collectEndorsementsView, whichstate.NewCollectEndorsementsViewwraps, lost that information for three of its failures, soerrors.Is(err, session.ErrDraining)and the like never matched in the caller.Fixes #2557. Unblocks #2558.
Investigation
Every error the view returns for a remote party, and whether a caller could match it:
mainerrors.New(payload), untypedsession.ErrRejectedand the reason's sentinel (ErrDraining,ErrBusy,ErrUnknownView), assession.RejectionErrordoescomm.ErrSessionClosedcontext.DeadlineExceededsyscall.ECONNREFUSED,*net.OpError)The view is shared by Fabric and Fabric-x apps, so both are covered.
NewParallelCollectEndorsementsOnProposalView, which the issue asks to check, already returns typed rejections: it receives through the JSON session, which callssession.RejectionError. Its timeout (time out reached on session) and closed session (received message is nil) are untyped too, but both come from the shared JSON session inplatform/view/services/comm/session/json.go, which many views use, and #2558 does not use this view. They are left out of this PR.Changes
platform/fabric/services/endorser/endorsement.go:session.RejectionError's error; any other error reply wraps nothing;comm.ErrSessionClosed, and the timeout wrapscontext.DeadlineExceeded, the existing sentinel rather than a new one;NewCollectEndorsementsViewgains a godoc listing the errors a caller can match. It also says that each endorsement is added to the transaction as soon as it verifies, this node's own included, and that a failure does not remove those added before it, while a party that fails before its reply verifies adds nothing;main: a small localtextErrorcarries the old text and unwraps to the sentinel;sessionvariables are renamed (sandsess), since they would shadow the imported package.platform/fabric/services/state/endorsement.go: the wrapper's godoc points to that list.docs/platform/fabric/fabric-sdk.md: a "Collecting endorsements" section with the same table, and when a failed attempt leaves the transaction as it was: a caller that asks one party at a time can pass the same transaction to another party.The errors gain types; their texts are the same as on
main, so log searches and callers that match on text keep working. Not breaking.Testing
TestCollectEndorsementsView_ErrorTypes(platform/fabric/services/endorser/endorsement_test.go) runs the view onnewCollectFixture, whose session reply each subtest controls. The timeout subtest builds the fixture in atesting/synctestbubble, so the one-minute wait passes at once. The rejection subtest also checks that the rejected party added nothing to the transaction. The view's context ending is covered by the existingTestCollectEndorsementsView_ReturnsWhenContextEnds.rejection:draining,busy,node_busy,unknown_view, and nothing appendedsession closedno reply before the timeouterror reply that is not a rejection: the text is the payload, and it is notErrRejectedgo test -race -count=3 -shuffle=ononplatform/fabric/services/endorserandplatform/fabric/services/state: passgo test ./platform/fabric/services/...: passmake checks: 0 issues