mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-18 05:30:37 +00:00
Handle WAL redo errors more gracefully.
Don't panic, but return an error to the caller, all the way up to the processing node instance that did the GetPage@LSN call.
This commit is contained in:
committed by
Stas Kelvich
parent
53b31f60be
commit
e74a812850
@@ -255,7 +255,14 @@ pub fn get_page_at_lsn(tag: BufferTag, lsn: u64) -> Result<Bytes, Box<dyn Error>
|
||||
while entry_content.apply_pending {
|
||||
entry_content = entry_rc.walredo_condvar.wait(entry_content).unwrap();
|
||||
}
|
||||
page_img = entry_content.page_image.as_ref().unwrap().clone();
|
||||
|
||||
// We should now have a page image. If we don't, it means that WAL redo
|
||||
// failed to reconstruct it. WAL redo should've logged that error already.
|
||||
page_img = match &entry_content.page_image {
|
||||
Some(p) => p.clone(),
|
||||
None => { return Err("could not apply WAL to reconstruct page image".into()); }
|
||||
};
|
||||
|
||||
} else {
|
||||
// No base image, and no WAL record. Huh?
|
||||
return Err(format!("no page image or WAL record for requested page"))?;
|
||||
|
||||
@@ -504,11 +504,26 @@ impl Connection {
|
||||
};
|
||||
|
||||
let inf_lsn = 0xffff_ffff_ffff_eeee;
|
||||
let msg = BeMessage::ZenithReadResponse(ZenithReadResponse {
|
||||
ok: true,
|
||||
n_blocks: 0,
|
||||
page: page_cache::get_page_at_lsn(buf_tag, inf_lsn).unwrap()
|
||||
});
|
||||
|
||||
let msg;
|
||||
{
|
||||
let p = page_cache::get_page_at_lsn(buf_tag, inf_lsn);
|
||||
if p.is_ok() {
|
||||
msg = ZenithReadResponse {
|
||||
ok: true,
|
||||
n_blocks: 0,
|
||||
page: p.unwrap()
|
||||
};
|
||||
} else {
|
||||
const ZERO_PAGE:[u8; 8192] = [0; 8192];
|
||||
msg = ZenithReadResponse {
|
||||
ok: false,
|
||||
n_blocks: 0,
|
||||
page: Bytes::from_static(&ZERO_PAGE)
|
||||
}
|
||||
}
|
||||
}
|
||||
let msg = BeMessage::ZenithReadResponse(msg);
|
||||
|
||||
self.write_message(&msg).await?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user