Skip to content

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Sep 30, 2025

Resolves #14805
When the same instance is passed to executor multiple times the context propagation virtual field gets overwritten and reset which makes context propagation unreliable. This issue is now easier to trigger after #14546 because previously some executor methods would wrap the given instance into another runnable that would also carry context. Even when the original shared instance had the context reset the wrapper still carried it. #14546 disabled propagating the context into the wrapper. We have previously already fixed this issue for execute(Runnable). This PR applies the same approach to other methods like submit(Runnable) and submit(Callable). Note that this fix only applies to tasks that are stateless lambdas. If a regular singleton is passed to executor it will have the same issue. To fix that we'd need to wrap all tasks similarly to what was proposed in #9325 I don't remember why that PR was never merged.

@laurit laurit requested a review from a team as a code owner September 30, 2025 10:59
Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

To fix that we'd need to wrap all tasks similarly to what was proposed in #9325 I don't remember why that PR was never merged.

Yeah, me either, seems worth revisiting

@laurit laurit merged commit a6c0489 into open-telemetry:main Oct 1, 2025
89 checks passed
@laurit laurit deleted the executor-stateless-lambda branch October 1, 2025 05:38
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.

Use release 2.20.1 version,ThreadPoolExecutor will loses TraceId in some cases
2 participants