Skip to content

Conversation

@awrichar
Copy link
Contributor

@awrichar awrichar commented Feb 1, 2022

Resolves #463

Work still pending:

  1. Remaining test coverage
  2. Adjusting other definition handlers (besides token pools) to use the new Finalize pattern

If the foundation looks good, I'll add on these remaining pieces.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
@codecov-commenter
Copy link

codecov-commenter commented Feb 1, 2022

Codecov Report

Merging #462 (17b2ffc) into main (c1f9507) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #462   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files         266      266           
  Lines       15101    15133   +32     
=======================================
+ Hits        15090    15122   +32     
  Misses         11       11           
Impacted Files Coverage Δ
internal/definitions/definition_handler.go 100.00% <100.00%> (ø)
...ternal/definitions/definition_handler_contracts.go 100.00% <100.00%> (ø)
...nternal/definitions/definition_handler_datatype.go 100.00% <100.00%> (ø)
...ternal/definitions/definition_handler_namespace.go 100.00% <100.00%> (ø)
...nal/definitions/definition_handler_network_node.go 100.00% <100.00%> (ø)
...rnal/definitions/definition_handler_network_org.go 100.00% <100.00%> (ø)
...ternal/definitions/definition_handler_tokenpool.go 100.00% <100.00%> (ø)
internal/events/aggregator.go 100.00% <100.00%> (ø)
internal/txcommon/txcommon.go 77.08% <100.00%> (-0.47%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1f9507...17b2ffc. Read the comment docs.

…ions

The bulk of the processing for a system definition broadcast occurs synchronously,
within a database RunAsGroup call.

For definitions that trigger calls out of FireFly (ie via plugins), there must be
an option to trigger steps outside RunAsGroup (and possibly another final set of
steps inside RunAsGroup).

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
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 is great - thanks for finding what looks like a pretty elegant solution to cracking this tough nut.

My only comments, are on your comments - and about being able to understand how to use the feature in the future within the code.

ActionWait
)

// DefinitionBatchActions are actions to be taken at the end of a definition batch - should only run if batch is successfully processed
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe worth mentioning that these callbacks are allowed to share state, by using a closure.

e.g. PreFinalize can contain idempotent logic that reads/updates the database, and calculates some kind of outcome, and then Finalize can write that outcome by referencing the variable from the closure.

// DefinitionBatchActions are actions to be taken at the end of a definition batch - should only run if batch is successfully processed
type DefinitionBatchActions struct {
// PreFinalize may perform a blocking action (possibly to an external connector) that should execute outside database RunAsGroup
PreFinalize func(ctx context.Context) error
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth noting that error returned from here, will cause the whole batch to "block" (indefinitely retry), just like ActionRetry would from HandleDefinitionBroadcast.

There is not (currently) any option to return an ActionReject in the PreFinalize phase

Copy link
Contributor

Choose a reason for hiding this comment

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

... after I wrote this, I found it's actually covered in the internal/events/aggregator comments - not sure if one should refer to the other, to avoid two places that we might forget to update the rules on.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
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.

Synchronous token pool activation causes database deadlock

3 participants