Unverified Commit 014e821c authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

improve disk read semantics around MustExist and AllowMissing (#99249)

Ensure two concurrent reads of a missing task both observe it as
missing: `AllowMissing` returns `None` for both, and `MustExist` panics
for both, rather than letting one reader mistake an intermediate blank
entry for a task. A missing requested Data or Meta key is conclusive;
the restore path also avoids retrying that key in a busy loop.

Add focused coverage for `task_pair`, `prepare_tasks`, missing
categories, and restore races. Stacked on #99383, which removes
suspended-operation serialization; this PR no longer filters persisted
operations.

<!-- fleet e2b0931e-5002-47b5-b5e1-3a96fbc88cab -->

---------
Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
parent a7640687
...@@ -396,9 +396,9 @@ impl TurboBackingStorage { ...@@ -396,9 +396,9 @@ impl TurboBackingStorage {
/// Reads the stored `category` for `task_id`. /// Reads the stored `category` for `task_id`.
/// ///
/// `None` means the database had no key for it. That is distinct from `Some` of an empty /// `None` means the database had no key for this category. That is distinct from `Some`
/// [`TaskStorage`] (a key that decoded to nothing), which is what lets a `MustExist` open tell /// of an empty [`TaskStorage`] (a key that decoded to nothing): `MustExist` treats a missing
/// "absent everywhere" from "present but empty". /// requested category as a missing task, regardless of the other category.
pub(crate) fn lookup_data( pub(crate) fn lookup_data(
&self, &self,
task_id: TaskId, task_id: TaskId,
...@@ -426,7 +426,7 @@ impl TurboBackingStorage { ...@@ -426,7 +426,7 @@ impl TurboBackingStorage {
&self, &self,
task_ids: &[TaskId], task_ids: &[TaskId],
category: SpecificTaskDataCategory, category: SpecificTaskDataCategory,
) -> Result<Vec<TaskStorage>> { ) -> Result<Vec<Option<TaskStorage>>> {
let inner = &*self.inner; let inner = &*self.inner;
let int_keys: Vec<_> = task_ids.iter().map(|&id| IntKey::new(*id)).collect(); let int_keys: Vec<_> = task_ids.iter().map(|&id| IntKey::new(*id)).collect();
let keys = int_keys.iter().map(|k| k.as_ref()).collect::<Vec<_>>(); let keys = int_keys.iter().map(|k| k.as_ref()).collect::<Vec<_>>();
...@@ -442,14 +442,15 @@ impl TurboBackingStorage { ...@@ -442,14 +442,15 @@ impl TurboBackingStorage {
bytes bytes
.into_iter() .into_iter()
.map(|opt_bytes| { .map(|opt_bytes| {
let Some(bytes) = opt_bytes else {
return Ok(None);
};
let mut storage = TaskStorage::new(); let mut storage = TaskStorage::new();
if let Some(bytes) = opt_bytes { let mut decoder = new_turbo_bincode_decoder(bytes.borrow());
let mut decoder = new_turbo_bincode_decoder(bytes.borrow()); storage
storage .decode(category, &mut decoder)
.decode(category, &mut decoder) .map_err(|e| anyhow::anyhow!("Failed to decode {category:?}: {e:?}"))?;
.map_err(|e| anyhow::anyhow!("Failed to decode {category:?}: {e:?}"))?; Ok(Some(storage))
}
Ok(storage)
}) })
.collect::<Result<Vec<_>>>() .collect::<Result<Vec<_>>>()
} }
......
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