-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
src: trace_events: fix race with metadata events #25235
Conversation
Multiple threads may be concurrently adding to the metadata_events list. Protect access with a mutex. Fixes: nodejs#24129
Has anyone gotten TSAN/ASAN builds working? They might help catch issues like this easier. |
@ofrobots - presence of mutexes are found to be problematic (ref: #25007) . While there is no specific issue as such to this PR, increase in the number of mutextes increases the chance of crashes at the non-cordinated process exit route; unless we arrive at a plan to control those (conditions such as attempting to lock a mutex that is already destroyed, attempting to destroy a mutex that is locked, etc). thoughts? |
@@ -145,6 +143,8 @@ class Agent { | |||
ConditionVariable initialize_writer_condvar_; | |||
uv_async_t initialize_writer_async_; | |||
std::set<AsyncTraceWriter*> to_be_initialized_; | |||
|
|||
Mutex metadata_events_mutex_; | |||
std::list<std::unique_ptr<TraceObject>> metadata_events_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a dumb question, but when does this list get cleared? Does it ever?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't and shouldn't really. These need to be cached and re-emitted whenever the trace file rolls over to a new file. There should only ever be a limited number of these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Metadata events are meta information about the process and environment rather than being events at particular points in time. In production scenarios, the trace events may be streamed across the network where only a trailing buffer is retained. The idea is that these metadata events should be periodically remitted to ensure that they are still available even if the start of the log is truncated.
@addaleax thanks for launching the CI. I had started one earlier as well: https://ci.nodejs.org/job/node-test-pull-request/19975/ which is unfinished but well-poised right. |
Landed in f39b3e3 |
Multiple threads may be concurrently adding to the metadata_events list. Protect access with a mutex. Fixes: nodejs#24129 PR-URL: nodejs#25235 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Multiple threads may be concurrently adding to the metadata_events list. Protect access with a mutex. Fixes: nodejs#24129 PR-URL: nodejs#25235 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Multiple threads may be concurrently adding to the metadata_events list. Protect access with a mutex. Fixes: nodejs#24129 PR-URL: nodejs#25235 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Multiple threads may be concurrently adding to the metadata_events list.
Protect access with a mutex.
Fixes: #24129
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesCI:
https://ci.nodejs.org/job/node-test-pull-request/19827/https://ci.nodejs.org/job/node-test-pull-request/19975/