Commit 3b77a6e2 authored by Tobias Koppers's avatar Tobias Koppers Committed by Luke Sandberg

Fix DashMap read-write self-deadlock in task_cache causing hangs (#92210)

parent b2f208ae
...@@ -1474,8 +1474,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1474,8 +1474,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
let is_root = task_type.native_fn.is_root; let is_root = task_type.native_fn.is_root;
// First check if the task exists in the cache which only uses a read lock // First check if the task exists in the cache which only uses a read lock
if let Some(task_id) = self.task_cache.get(&task_type) { // .map(|r| *r) copies the TaskId and drops the DashMap Ref (releasing the read lock)
let task_id = *task_id; // before ConnectChildOperation::run, which may re-enter task_cache with a write lock.
if let Some(task_id) = self.task_cache.get(&task_type).map(|r| *r) {
self.track_cache_hit(&task_type); self.track_cache_hit(&task_type);
self.connect_child( self.connect_child(
parent_task, parent_task,
...@@ -1564,9 +1565,10 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1564,9 +1565,10 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
/* cell_id */ None, /* cell_id */ None,
); );
} }
// First check if the task exists in the cache which only uses a read lock // First check if the task exists in the cache which only uses a read lock.
if let Some(task_id) = self.task_cache.get(&task_type) { // .map(|r| *r) copies the TaskId and drops the DashMap Ref (releasing the read lock)
let task_id = *task_id; // before ConnectChildOperation::run, which may re-enter task_cache with a write lock.
if let Some(task_id) = self.task_cache.get(&task_type).map(|r| *r) {
self.track_cache_hit(&task_type); self.track_cache_hit(&task_type);
self.connect_child( self.connect_child(
parent_task, parent_task,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment