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

Surface message rejection reason to API #1336

Merged
merged 1 commit into from
Jun 7, 2023

Conversation

awrichar
Copy link
Contributor

@awrichar awrichar commented Jun 7, 2023

Proposal to add a "reject_reason" to messages (ie to database and API), which will be populated with the error text whenever a message is rejected. Previously this reason would only be logged, so the hope is that this assists in debugging when a message is rejected for an unexpected reason.

Note that this does slightly reduce the performance of inserting rejected messages, because we must insert them one-by-one instead of in one large update (but I think the net benefit of having the extra info far outweighs the cost, since this is a non-happy path anyway).

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
@@ -618,10 +622,6 @@ func (ag *aggregator) readyForDispatch(ctx context.Context, msg *core.Message, d
var handlerResult definitions.HandlerResult
handlerResult, err = ag.definitions.HandleDefinitionBroadcast(ctx, &state.BatchState, msg, data, tx)
log.L(ctx).Infof("Result of definition broadcast '%s' [%s]: %s", msg.Header.Tag, msg.Header.ID, handlerResult.Action)
if handlerResult.Action == core.ActionReject {
log.L(ctx).Infof("Definition broadcast '%s' rejected: %s", msg.Header.ID, err)
err = nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this block should now fall through and return the error to its caller (line 528), which will then log the error and add it to the message, but should not cause retries. I'm trying to be very careful not to reintroduce the bugs fixed in #1278.

@codecov-commenter
Copy link

Codecov Report

Merging #1336 (81be3e2) into main (26f0245) will decrease coverage by 0.02%.
The diff coverage is 93.75%.

@@             Coverage Diff             @@
##              main    #1336      +/-   ##
===========================================
- Coverage   100.00%   99.98%   -0.02%     
===========================================
  Files          314      314              
  Lines        21419    21453      +34     
===========================================
+ Hits         21419    21449      +30     
- Misses           0        2       +2     
- Partials         0        2       +2     
Impacted Files Coverage Δ
pkg/core/message.go 100.00% <ø> (ø)
internal/events/aggregator_batch_state.go 99.10% <90.90%> (-0.90%) ⬇️
internal/data/data_manager.go 100.00% <100.00%> (ø)
internal/database/sqlcommon/message_sql.go 100.00% <100.00%> (ø)
internal/events/aggregator.go 100.00% <100.00%> (ø)

... and 13 files with indirect coverage changes

Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

This looks great to me 👍

@peterbroadhurst peterbroadhurst merged commit d7f53ff into hyperledger:main Jun 7, 2023
@peterbroadhurst peterbroadhurst deleted the reject branch June 7, 2023 16:12
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.

3 participants