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

On fail should only be allowed with regular-compound-stmt #37315

Closed
pcnfernando opened this issue Aug 9, 2022 · 5 comments
Closed

On fail should only be allowed with regular-compound-stmt #37315

pcnfernando opened this issue Aug 9, 2022 · 5 comments
Assignees
Labels
Points/2 Equivalent to two days effort Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug Type/SpecDeviation

Comments

@pcnfernando
Copy link
Member

Description:
Ref https://ballerina.io/spec/lang/master/#stmt-with-on-fail

Steps to reproduce:

Affected Versions:
2201.1.1

OS, DB, other environment details and versions:

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

@pcnfernando pcnfernando added Type/Bug Type/SpecDeviation Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Aug 9, 2022
@gayalkuruppu
Copy link
Contributor

For now TransactionStatementNode and RetryStatementNode has an Optional<OnFailClauseNode> onFailClause() and the on fail is allowed.

@pcnfernando
Copy link
Member Author

Original impl based on ballerina-platform/ballerina-spec#337 (comment)

@buehlefs
Copy link

What is the reason on fail support is removed for transactions? Updating the spec to specifically support it for transaction blocks could also be an option here, as there is a clear use case for this feature.

For example, I use this extensively to streamline error handling of transaction blocks (since all my database calls are wrapped in transactions anyway). The alternatives to this are:

  • Checking every single result for errors -> ~1 extra if statement per result
  • Wrapping the transaction in a do block with on fail -> one extra level of nesting
  • Refactoring the transactions into individual functions -> the best choice but creates many single-use functions just for better error handling

The on fail of transaction blocks could also be interpreted as syntactic sugar for do { transaction {...} } on fail .... This could be useful to simplify defining the semantics in combination with retry of transactions.

@SasinduDilshara
Copy link
Contributor

Had a chat with internal team and decided to allow on fail for transaction and retry statements

Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Points/2 Equivalent to two days effort Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug Type/SpecDeviation
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants