Unverified Commit 2e1e5958 authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

turbo-tasks-backend: fix snapshot coordination races + extract SnapshotCoordinator (#93416)

Hold a lock while persisting so two snapshots cannot execute
concurrently

* Currently if `stop` is called while an idle snapshot is running, then
snapshotting can race with itself, this can corrupt the use of the
`in_progress_operations` parameter since two threads will `fetch_or`
with it and wait for the bit to be cleared

Abort the process if `panic!` occurs during task spawning
* Currently if `try_start_task_execution` panics it ends up hanging a
task which can deadlock the process, in this case we have no better
option than to just log and abort.
* I considered strategies that would 'poison' the task or possibly all
of turbo-tasks and this is attractive but i believe fundamentally
unsafe, the most likely cause of these panics is something wrong with
state tracking in the backend, so exiting is all we can do
parent 818aa245
...@@ -26,8 +26,8 @@ use turbo_tasks::{ ...@@ -26,8 +26,8 @@ use turbo_tasks::{
use self::aggregation_update::ComputeDirtyAndCleanUpdate; use self::aggregation_update::ComputeDirtyAndCleanUpdate;
use crate::{ use crate::{
backend::{ backend::{
EventDescription, OperationGuard, TaskDataCategory, TurboTasksBackend, EventDescription, TaskDataCategory, TurboTasksBackend, TurboTasksBackendInner,
TurboTasksBackendInner, snapshot_coordinator::OperationGuard,
storage::{SpecificTaskDataCategory, StorageWriteGuard}, storage::{SpecificTaskDataCategory, StorageWriteGuard},
storage_schema::{TaskStorage, TaskStorageAccessors}, storage_schema::{TaskStorage, TaskStorageAccessors},
}, },
...@@ -168,7 +168,7 @@ impl TaskLockCounter { ...@@ -168,7 +168,7 @@ impl TaskLockCounter {
pub struct ExecuteContextImpl<'e, B: BackingStorage> { pub struct ExecuteContextImpl<'e, B: BackingStorage> {
backend: &'e TurboTasksBackendInner<B>, backend: &'e TurboTasksBackendInner<B>,
turbo_tasks: &'e dyn TurboTasksBackendApi<TurboTasksBackend<B>>, turbo_tasks: &'e dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
_operation_guard: Option<OperationGuard<'e, B>>, _operation_guard: Option<OperationGuard<'e, AnyOperation>>,
task_lock_counter: TaskLockCounter, task_lock_counter: TaskLockCounter,
} }
......
This diff is collapsed.
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