Skip to content

Commit bbf21cc

Browse files
committed
Add comment about performing invalidation before prevent_write
1 parent 5878d20 commit bbf21cc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

turbopack/crates/turbo-tasks-backend/src/kv_backing_storage.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,11 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorage
466466
}
467467

468468
fn invalidate(&self) -> Result<()> {
469+
// `base_path` can be `None` for a `NoopKvDb`
469470
if let Some(base_path) = &self.base_path {
470-
// `base_path` can be `None` for a `NoopKvDb`
471+
// Invalidate first, as it's a very fast atomic operation. `prevent_writes` is allowed
472+
// to be slower (e.g. wait for a lock) and is allowed to corrupt the database with
473+
// partial writes.
471474
invalidate_db(base_path)?;
472475
self.database.prevent_writes()
473476
}

0 commit comments

Comments
 (0)