mirror of
https://github.com/neondatabase/neon.git
synced 2026-06-04 22:10:39 +00:00
Correctly handle Unlink message in GC for SLRU
This commit is contained in:
@@ -267,6 +267,7 @@ impl Timeline for ObjectTimeline {
|
||||
}
|
||||
|
||||
fn get_page_at_lsn_nowait(&self, tag: ObjectTag, lsn: Lsn) -> Result<Bytes> {
|
||||
const ZERO_PAGE: [u8; 8192] = [0u8; 8192];
|
||||
// Look up the page entry. If it's a page image, return that. If it's a WAL record,
|
||||
// ask the WAL redo service to reconstruct the page image from the WAL records.
|
||||
let searchkey = ObjectKey {
|
||||
@@ -289,7 +290,7 @@ impl Timeline for ObjectTimeline {
|
||||
|
||||
self.put_page_image(tag, lsn, page_img.clone())?;
|
||||
}
|
||||
x => bail!("Unexpected object value: {:?}", x),
|
||||
_ => page_img = Bytes::from_static(&ZERO_PAGE),
|
||||
}
|
||||
// FIXME: assumes little-endian. Only used for the debugging log though
|
||||
let page_lsn_hi = u32::from_le_bytes(page_img.get(0..4).unwrap().try_into().unwrap());
|
||||
@@ -304,7 +305,6 @@ impl Timeline for ObjectTimeline {
|
||||
);
|
||||
return Ok(page_img);
|
||||
}
|
||||
static ZERO_PAGE: [u8; 8192] = [0u8; 8192];
|
||||
trace!("page {:?} at {} not found", tag, lsn);
|
||||
Ok(Bytes::from_static(&ZERO_PAGE))
|
||||
/* return Err("could not find page image")?; */
|
||||
|
||||
@@ -241,9 +241,15 @@ impl ReceiveWalConn {
|
||||
my_info.server = server_info.clone();
|
||||
my_info.server.node_id = node_id;
|
||||
|
||||
/* Need to save incompleted my_info in timeline to provide wal_seg_size for find_end_of_wal */
|
||||
self.timeline.get().set_info(&my_info);
|
||||
|
||||
/* Calculate WAL end based on local data */
|
||||
let (flush_lsn, timeline) = self.timeline.find_end_of_wal(&self.conf.data_dir, true);
|
||||
my_info.flush_lsn = flush_lsn;
|
||||
|
||||
let min_lsn = Lsn((server_info.wal_seg_size as u64) * 2); // strt from second segment because of pg_resetwal
|
||||
my_info.restart_lsn = Lsn::max(my_info.restart_lsn, min_lsn);
|
||||
my_info.server.timeline = timeline;
|
||||
|
||||
/* Report my identifier to proposer */
|
||||
|
||||
@@ -233,7 +233,9 @@ impl TimelineTools for Option<Arc<Timeline>> {
|
||||
fn find_end_of_wal(&self, data_dir: &Path, precise: bool) -> (Lsn, TimeLineID) {
|
||||
let seg_size = self.get().get_info().server.wal_seg_size as usize;
|
||||
let (lsn, timeline) = find_end_of_wal(data_dir, seg_size, precise);
|
||||
(Lsn(lsn), timeline)
|
||||
let wal_start = Lsn((seg_size * 2) as u64); // FIXME: handle pg_resetwal
|
||||
let lsn = Lsn::max(Lsn(lsn), wal_start);
|
||||
(lsn, timeline)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user