-
Notifications
You must be signed in to change notification settings - Fork 734
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
Bad interaction between tracing-error and tracing #1565
Comments
This is a workaround for tokio-rs/tracing#1565
* Allow root_span to wrap the full middlware chain, not just the output future * Build error string outside of span.record This is a workaround for tokio-rs/tracing#1565 * Reference issue being worked-around as comment
* Allow root_span to wrap the full middlware chain, not just the output future * Build error string outside of span.record This is a workaround for tokio-rs/tracing#1565 * Reference issue being worked-around as comment
On the current version of the tracing libraries this no longer panics, and instead deadlocks
|
Just chiming in to say that we're also experiencing this behavior when using tracing and OTLP. Deadlocks happen when tracing the captured span within a span |
Thanks, @thehabbos007. cc @CiaranMn @TimDiekmann |
This is caused by the fact that the fields are stored/cached in formatted form inside a tracing/tracing-subscriber/src/fmt/fmt_layer.rs Lines 832 to 835 in 4302064
Later, when the tracing/tracing-error/src/layer.rs Lines 93 to 97 in 4302064
I can see 5 possible solutions:
let trace = format!("{trace:?}");
span.record("trace", trace);
@thehabbos007 While very similar, that issue is slightly different, as the extensions are locked for a different reason. The first two solutions however are the same (see tokio-rs/tracing-opentelemetry#59). |
I've had this issue also. looks like it has been fixed by "tracing-opentelemetry v0.22.0". Thanks!. |
Some thoughts on the possible solutions:
This would work, although someone might still try use the extensions in their own implementation. I think this is a reasonable risk to take.
This has a problem when someone uses the same span from multiple threads at the same time. When there are no extensions, the other thread may conclude it has to create new empty ones and then it will effectively overwrite all fields that have been collected up to this point. Or it could detect this when it tried to insert the fields and try again or merge the two fields while it holds the lock since now it doesn't need to call the visitors again. Or we can add a fallible
This runs to the same problem with parallel writes as the last option, but now it's harder to notice that the content has changed or merge the two versions.
Here multi-threaded spans work, but we need a way to combine the two |
Bug Report
Version
Platform
Description
When passing a type containing tracing-error's SpanTrace to a span's
record
method, A rwlock is attemped to lock while it's already held, which would result in a deadlock if it didn't panic instead.Repro:
Originally reported here: LukeMathWalker/tracing-actix-web#36
The text was updated successfully, but these errors were encountered: