From f0030ae003a2b0e10ce1267f918572fba07a4f66 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 3 Aug 2021 13:59:51 +0300 Subject: [PATCH] Handle SLRU ZERO records directly by storing an all-zeros page image. It's simpler than storing the original WAL record. --- pageserver/src/restore_local_repo.rs | 6 ++++-- pageserver/src/walredo.rs | 17 +++-------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/pageserver/src/restore_local_repo.rs b/pageserver/src/restore_local_repo.rs index cf50af23d4..140172272a 100644 --- a/pageserver/src/restore_local_repo.rs +++ b/pageserver/src/restore_local_repo.rs @@ -25,6 +25,8 @@ use zenith_utils::lsn::Lsn; const MAX_MBR_BLKNO: u32 = pg_constants::MAX_MULTIXACT_ID / pg_constants::MULTIXACT_MEMBERS_PER_PAGE as u32; +const ZERO_PAGE: Bytes = Bytes::from_static(&[0u8; 8192]); + /// /// Import all relation data pages from local disk into the repository. /// @@ -415,7 +417,7 @@ pub fn save_decoded_record( rec: recdata.clone(), main_data_offset: decoded.main_data_offset as u32, }; - timeline.put_wal_record(tag, rec)?; + timeline.put_page_image(tag, lsn, ZERO_PAGE, false)?; } else { assert!(info == pg_constants::CLOG_TRUNCATE); checkpoint.oldestXid = buf.get_u32_le(); @@ -477,7 +479,7 @@ pub fn save_decoded_record( } else { ObjectTag::MultiXactMembers(SlruBufferTag { blknum }) }; - timeline.put_wal_record(tag, rec)?; + timeline.put_page_image(tag, lsn, ZERO_PAGE, false)?; } else if info == pg_constants::XLOG_MULTIXACT_CREATE_ID { let xlrec = XlMultiXactCreate::decode(&mut buf); save_multixact_create_record(checkpoint, timeline, lsn, &xlrec, decoded)?; diff --git a/pageserver/src/walredo.rs b/pageserver/src/walredo.rs index 102c8eb347..4a2820aeba 100644 --- a/pageserver/src/walredo.rs +++ b/pageserver/src/walredo.rs @@ -314,13 +314,7 @@ impl PostgresRedoManagerInternal { buf.advance(skip); } - if xlogrec.xl_rmid == pg_constants::RM_CLOG_ID { - let info = xlogrec.xl_info & !pg_constants::XLR_INFO_MASK; - if info == pg_constants::CLOG_ZEROPAGE { - // The only operation we need to implement is CLOG_ZEROPAGE - page.copy_from_slice(&ZERO_PAGE); - } - } else if xlogrec.xl_rmid == pg_constants::RM_XACT_ID { + if xlogrec.xl_rmid == pg_constants::RM_XACT_ID { // Transaction manager stuff let info = xlogrec.xl_info & pg_constants::XLOG_XACT_OPMASK; let tag_blknum = match tag { @@ -376,14 +370,9 @@ impl PostgresRedoManagerInternal { } } } else if xlogrec.xl_rmid == pg_constants::RM_MULTIXACT_ID { - // Multiexact operations + // Multixact operations let info = xlogrec.xl_info & pg_constants::XLR_RMGR_INFO_MASK; - if info == pg_constants::XLOG_MULTIXACT_ZERO_OFF_PAGE - || info == pg_constants::XLOG_MULTIXACT_ZERO_MEM_PAGE - { - // Just need to zero page - page.copy_from_slice(&ZERO_PAGE); - } else if info == pg_constants::XLOG_MULTIXACT_CREATE_ID { + if info == pg_constants::XLOG_MULTIXACT_CREATE_ID { let xlrec = XlMultiXactCreate::decode(&mut buf); if let ObjectTag::MultiXactMembers(slru) = tag { for i in 0..xlrec.nmembers {