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

Rewrite parts of the executors instrumentation to wrap Runnables #9324

Open
mateuszrzeszutek opened this issue Aug 28, 2023 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@mateuszrzeszutek
Copy link
Member

Is your feature request related to a problem? Please describe.

See #9175 and #9179

There is an issue with the Executor#execute(Runnable) instrumentation caused by our handling of state: when you submit the same Runnable instance to the execute() method, the agent attaches context to it using a virtual field. Because it's the same instance, and we don't create a wrapper, the passed state gets mangled when said runnable gets executed concurrently in several threads.
This problem does not surface for other ExecutorService methods (e.g. schedule()) in the java.concurrent executor implementations because they all always create a new FutureTask and then delegate to execute(); so the runnable is a fresh instance every time.

Describe the solution you'd like

For the java.concurrent executors, we could ignore all the extra methods that delegate to execute() and just instrument execute() itself, creating a new Runnable wrapper every time it gets called.

Extra care should be applied to non-standard executors, or executors that use non-standard queues (e.g. Slick AsyncExecutor)

Describe alternatives you've considered

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant