Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
So what hapens is this: broadcast_validated_edges_trigger is trigger, which means that's a callback which gets executing on actor's event loop from time to time. In this trigger, we create a span. We also execute an async operation (sendign AddVerifiedEdges message). We want the spans to connect, so we use parent: &span in the callback. The problem here though is that, because we move the original entered span into the closure, the span actually remains active even after broadcast_validated_edges_trigger function returns! We have a span leak of sorts, and whatever else ends up being executed on the actor loop (inlcuding subsequent calls to the trigger!) would have this run-away span on the stack. So we get a very deep (and malformed) stack of the spans. And then eventually it stack overflows. This is essentially the same problem as the one in https://onesignal.com/blog/solving-memory-leaks-in-rust/. We fix this by using the `Instrument` trait for the problematic future, and the `let run_later_span =` pattern for `run_later` usages. We *could* introduce a second helper for `run_later`, but I'd rather avoid that here -- it seems that the whole `run_later` infra can be replaced with tracing, but I'd rather not do that in this PR.
- Loading branch information