-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Description
There is a race condition in DispatcherImpl, between this write in initializeStats on the main thread:
stats_prefix_ = prefix + "dispatcher";and this read in run on the worker threads:
if (!stats_prefix_.empty())Disconcertingly, this wasn't caught by our tsan build, so it is not easy to reproduce. @AndresGuedez caught this when trying to do our weekly import at Google.
The code is written this way because it's important to log the thread ID corresponding to the worker's stat prefix for debugging:
if (!stats_prefix_.empty()) {
ENVOY_LOG(debug, "running {} on thread {}", stats_prefix_, run_tid_->debugString());
}I'm sort of hesitant to introduce a mutex just for this -- it feels like we just shouldn't be splitting this work across threads this way at all -- I think the correct fix is just to ensure that stats are initialized on the dispatcher's thread, at which point we have a thread id.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels