Open pcnfernando opened 3 years ago
Ideally there should be a proper way from the runtime to propagate thread local variable from the parent strand to the child strand. The PR ballerina-platform/ballerina-lang#31466 is a new API to access the complete property map and pass it over. That will reduce the cost of access each property and setting it back like the improvement done in the ballerina-platform/module-ballerina-http#496
But it's better if they provide propagation from their end. case 1: When ballerina thread start, i.e invoke resource function from java, properties has to be passed case 2: When another thread start after a parent thread execution, parent properties are propagated internally
The solution is pending and the runtime team is not in favour of providing such API. Update: The issue is more of an improvement rather than a bug
While invoking the client method as async(https://github.com/ballerina-platform/module-ballerina-http/blob/master/http-native/src/main/java/org/ballerinalang/net/http/actions/httpclient/HttpClientAction.java#L129), we assume that the env will be the same for the newly created strand as well. Atm, this is not the case. We set the parent strand as null at the async invocation (https://github.com/ballerina-platform/ballerina-lang/blob/master/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java#L96).
As a workaround for service-based transactions, we created a submap from the parent's global properties and propagated it in https://github.com/ballerina-platform/module-ballerina-http/pull/258