-
Notifications
You must be signed in to change notification settings - Fork 453
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]: PeriodicReader::shutdown()
deadlocks on current thread runtime.
#2056
Comments
This could be some design bug in the metric aggregation. Related to BatchProcessing as well, as that is another place where OTel does background processing. I don't have a good answer at the moment, but you can expect a solution soon. We just finished redesigning the metrics hot path (the aggregation path), and the next major item left is to revisit the periodicreader part. We are exploring a redesign, where OTel will spin up its own background thread for doing metric collect, batch exporting(logs,spans), and not rely on async runtimes at all. Will be sharing some design ideas soon, would love to get your inputs there. |
Could be the same: #868 (comment) |
Running PeriodicReader with the actix-web runtime started with |
The way I understand currently there are two options:
|
Added this to a test (obviously ignored to not make CI red) |
@inahga Could you review the approach in #2142 where we spin up a dedicated thread for metrics export in the background? I am trying to see if that'd be a good default than relying on async runtimes. (ability to bring own async runtimes like today is still planned to be a supported feature in the future) |
Sorry for replying so late. The approach LGTM, it's probably how I would have done it. |
Closing this issue, as just switched the default to use own thread, and not rely on async runtimes. Also tests are added for normal main, tokio::main, tokio::main with single-thread. |
What happened?
When using the
SdkMeterProvider
with aPeriodicReader
on a tokiocurrent_thread
runtime, the program hangs when theSdkMeterProvider
leaves scope.Example reproducer: Take the
registration_triggers_collection()
test function inopentelemetry-sdk/src/metrics/periodic_reader.rs
, and run it on acurrent_thread
runtime:The problematic code looks to be in
PeriodicReader::shutdown()
, where we send a shutdown signal and wait for receipt on a oneshot channel in ablock_on
statement. When executed in the context of aDrop
, there is no runtime to advance the other side of the channel, so we hang indefinitely.It's not a big deal, it can be worked around by using a multi-thread runtime, or by calling
shutdown()
ahead of time. It's just unexpected and easy to trip up on, since tokio tests default to a current thread runtime.More than happy to fix it myself, but wanted to get maintainer input first. (It may be the right answer is to not use a current thread runtime?)
API Version
0.24.0
SDK Version
0.24.1
What Exporter(s) are you seeing the problem on?
N/A
Relevant log output
No response
The text was updated successfully, but these errors were encountered: