-
Notifications
You must be signed in to change notification settings - Fork 271
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
QueryAnalysisLayer
holds spans open through tokio::sync::Mutex
when tracing
feature enabled
#4074
Comments
I have been investigating memory issues in the router over the last week and I think there may be some kind of issue related to tracing or telemetry which I haven't pinned down yet. I was excited when I saw this, but then realised that we don't enable the I agree that this seems like an under-notified feature (e.g.: It would be good to have the doc comment on Using |
Yeah the alternatives don't seem to work here, besides for disabling console : tracing for now. I'll bring this up to Tokio folks, I'm not sure how this use case can even work. |
Testing with I need to think about this more but it seems like any traces that can potentially be held open across multiple requests would cause this issue 🤔 |
I'm going to close this as this is more of a general tracing thing, but would love some thoughts on this general problem if anyone has any 😄 |
A
tokio::sync::Mutex
with thetracing
feature enabled holds atracing::Span
.This span holds a "reference" (in the sense that it increments the ref count, through
clone_span
) to a parent span. In the router, anArc<Mutex<Compiler>>
is stored in QueryAnalysisLayer's cache, which is only cleared on router reload. When the mutex is created, its span increments the ref count of therouter
span.This leads to the router span never exiting since it is never fully dropped (refs > 1).
I am really not sure about the fix here. An alternative is
Mutex::const_new
which not create a span. Maybe astd::sync::Mutex
is fine here too. I was surprised by this behavior. Caching mutexes across requests within a request trace seems dangerous when thetracing
feature is enabled.Note that this only affects the first request for a particular
QueryAnalysisKey
.The text was updated successfully, but these errors were encountered: