This commit is contained in:
Christian Schwarz
2024-09-14 12:05:42 +00:00
parent 3640824553
commit 709a6ad29b

View File

@@ -87,17 +87,13 @@ pub(crate) struct VectoredValueReconstructState {
Lsn,
tokio::sync::oneshot::Receiver<Result<Bytes, std::io::Error>>,
)>,
pub(crate) img: Option<(
Lsn,
tokio::sync::oneshot::Receiver<Result<Bytes, std::io::Error>>,
)>,
pub(crate) situation: ValueReconstructSituation,
}
impl VectoredValueReconstructState {
fn get_cached_lsn(&self) -> Option<Lsn> {
self.img.as_ref().map(|img| img.0)
None
}
}
@@ -107,6 +103,7 @@ pub(crate) async fn convert(
) -> Result<ValueReconstructState, PageReconstructError> {
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)
}