ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.66k stars 748 forks source link

Observability "$invocation$bb29$isError" variable is added twice when using more than 2 db calls with transaction #32074

Closed niveathika closed 3 years ago

niveathika commented 3 years ago

Description: $subject

Steps to reproduce:

  1. Setup a MySQL DB with the following table,

    CREATE TABLE IF NOT EXISTS Customers(
    customerId INTEGER NOT NULL AUTO_INCREMENT,
    firstName  VARCHAR(300),
    lastName  VARCHAR(300),
    registrationID INTEGER,
    creditLimit DOUBLE,
    country  VARCHAR(300),
    PRIMARY KEY (customerId)
    );
  2. Compile,

    
    import ballerina/io;
    import ballerina/sql;
    import ballerinax/mysql;
    import ballerinax/mysql.driver as _;

type TransactionResultCount record { int COUNTVAL; };

public function main() returns error? { // Fill in MySQL DB credentials mysql:Client dbClient = check new(user = "", password="", database = ""); int retryVal = -1; boolean committedBlockExecuted = false; transaction { sql:ExecutionResult|sql:Error res = dbClient->execute("Insert into Customers (firstName,lastName,registrationID,creditLimit," + "country) values ('James', 'Clerk', 200, 5000.75, 'USA')"); sql:ExecutionResult|sql:Error res1 = dbClient->execute("Insert into Customers (firstName,lastName,registrationID,creditLimit,country) " + "values ('James', 'Clerk', 200, 5000.75, 'USA')"); io:println(res1);

    var commitResult = commit;
    if(commitResult is ()){
        io:println("committedBlockExecuted");
    }
    io:println(res);

}

//check whether update action is performed
int count = 0;
stream<TransactionResultCount, sql:Error?> streamData = dbClient->query("Select COUNT(*) as " +
    "countval from Customers where registrationID = 201");
record {|TransactionResultCount value;|}? data = check streamData.next();
io:println(data);

check dbClient.close();

}



If you extract the mainFrame class in the generated jar, you can observe "invocation$bb29$isError" is added twice.

**Affected Versions:**
Beta 2
niveathika commented 3 years ago

https://github.com/ballerina-platform/ballerina-standard-library/issues/120 is blocked due to this. @nadundesilva Shall we prioritize this issue?