From 709a6ad29ba528a84f7fb461a345df4cb6f5fc00 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sat, 14 Sep 2024 12:05:42 +0000 Subject: [PATCH] WIP --- pageserver/src/tenant/storage_layer.rs | 38 ++++++++------------------ 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/pageserver/src/tenant/storage_layer.rs b/pageserver/src/tenant/storage_layer.rs index f30e068883..a344948d5c 100644 --- a/pageserver/src/tenant/storage_layer.rs +++ b/pageserver/src/tenant/storage_layer.rs @@ -87,17 +87,13 @@ pub(crate) struct VectoredValueReconstructState { Lsn, tokio::sync::oneshot::Receiver>, )>, - pub(crate) img: Option<( - Lsn, - tokio::sync::oneshot::Receiver>, - )>, pub(crate) situation: ValueReconstructSituation, } impl VectoredValueReconstructState { fn get_cached_lsn(&self) -> Option { - self.img.as_ref().map(|img| img.0) + None } } @@ -107,6 +103,7 @@ pub(crate) async fn convert( ) -> Result { let mut to = ValueReconstructState::default(); + let mut inited = false; for (lsn, fut) in from.records { match fut.await { Ok(res) => match res { @@ -114,13 +111,18 @@ pub(crate) async fn convert( let value = Value::des(&bytes) .map_err(|err| PageReconstructError::Other(err.into()))?; - match value { - Value::WalRecord(rec) => { + match (inited, value) { + (true, _) => { + panic!("multiple will_init records, plan was wrong"); + } + (false, Value::WalRecord(rec)) => { + inited = rec.will_init(); to.records.push((lsn, rec)); - }, - Value::Image(img) => { + } + (false, Value::Image(img)) => { assert!(to.img.is_none()); to.img = Some((lsn, img)); + inited = true; } } } @@ -133,23 +135,7 @@ pub(crate) async fn convert( } } } - - if to.img.is_none() && from.img.is_some() { - let (lsn, fut) = from.img.expect("Has an image"); - match fut.await { - Ok(res) => match res { - Ok(bytes) => { - to.img = Some((lsn, bytes)); - } - Err(err) => { - return Err(PageReconstructError::Other(err.into())); - } - }, - Err(err) => { - return Err(PageReconstructError::Other(err.into())); - } - } - } + // do not assert inited=true here because it's kinda legitimate to ask for key that doesn't exist Ok(to) }