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

[Bug]: Exit out of a transaction-block without executing a commit action or a rollback-stmt #42759

Open
dsplayerX opened this issue May 16, 2024 · 0 comments
Labels
Area/Compiler Lang/Transactions Ballerina Transaction and its implementation related issued Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug

Comments

@dsplayerX
Copy link
Contributor

dsplayerX commented May 16, 2024

Description

According to the specification, any exit out of the transaction block that is neither a panic nor a fail should trigger either a commit-action or a rollback-statement.

The provided code sample demonstrates a scenario where the exit out of the transaction statement-block doesn't execute a commit action or a rollback statement, which is a violation of the specification. It doesn't raise any compiler errors and executes without any runtime errors.

transaction {
        transaction:onCommit(isolated function(transaction:Info info) {
                    io:println("Commit triggered");
                });
        transaction:onRollback(isolated function(transaction:Info info, error? cause, boolean willRetry) {
                    io:println("Rollback triggered");
                });

        boolean bool = false;

        if bool {
            check commit;
        }
    }

Steps to Reproduce

import ballerina/io;

public function main() returns error? {

    transaction {
        transaction:onCommit(isolated function(transaction:Info info) {
                    io:println("Commit triggered");
                });
        transaction:onRollback(isolated function(transaction:Info info, error? cause, boolean willRetry) {
                    io:println("Rollback triggered");
                });

        boolean bool = false;

        if bool {
            check commit;
        }
    }
}

Affected Version(s)

2201.9.0

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@dsplayerX dsplayerX added Type/Bug Area/Compiler Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Lang/Transactions Ballerina Transaction and its implementation related issued labels May 16, 2024
@dsplayerX dsplayerX changed the title [Bug]: Exit out of a transaction-block without executing a rollback-stmt [Bug]: Exit out of a transaction-block without executing a commit action or a rollback-stmt May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Compiler Lang/Transactions Ballerina Transaction and its implementation related issued Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug
Projects
None yet
Development

No branches or pull requests

1 participant