Unverified Commit 9e150930 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

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

parent 3e015884
...@@ -1532,8 +1532,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1532,8 +1532,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
// Create a single ExecuteContext for both lookup and connect_child // Create a single ExecuteContext for both lookup and connect_child
let mut ctx = self.execute_context(turbo_tasks); let mut ctx = self.execute_context(turbo_tasks);
// 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);
operation::ConnectChildOperation::run( operation::ConnectChildOperation::run(
parent_task, parent_task,
...@@ -1614,9 +1615,10 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1614,9 +1615,10 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
); );
} }
let mut ctx = self.execute_context(turbo_tasks); let mut ctx = self.execute_context(turbo_tasks);
// 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);
operation::ConnectChildOperation::run( operation::ConnectChildOperation::run(
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