diff --git a/pageserver/src/walredo.rs b/pageserver/src/walredo.rs index 6918698f29..3bec2846e9 100644 --- a/pageserver/src/walredo.rs +++ b/pageserver/src/walredo.rs @@ -414,7 +414,7 @@ impl PostgresRedoManager { "ClearVisibilityMapFlags record on unexpected rel {}", rel ); - if let Some(heap_blkno) = *new_heap_blkno { + let mut doit = |heap_blkno| { // Calculate the VM block and offset that corresponds to the heap block. let map_block = pg_constants::HEAPBLK_TO_MAPBLOCK(heap_blkno); let map_byte = pg_constants::HEAPBLK_TO_MAPBYTE(heap_blkno); @@ -427,19 +427,12 @@ impl PostgresRedoManager { let map = &mut page[pg_constants::MAXALIGN_SIZE_OF_PAGE_HEADER_DATA..]; map[map_byte as usize] &= !(flags << map_offset); + }; + if let Some(heap_blkno) = *new_heap_blkno { + doit(heap_blkno); } - - // Repeat for 'old_heap_blkno', if any if let Some(heap_blkno) = *old_heap_blkno { - let map_block = pg_constants::HEAPBLK_TO_MAPBLOCK(heap_blkno); - let map_byte = pg_constants::HEAPBLK_TO_MAPBYTE(heap_blkno); - let map_offset = pg_constants::HEAPBLK_TO_OFFSET(heap_blkno); - - assert!(map_block == blknum); - - let map = &mut page[pg_constants::MAXALIGN_SIZE_OF_PAGE_HEADER_DATA..]; - - map[map_byte as usize] &= !(flags << map_offset); + doit(heap_blkno); } } // Non-relational WAL records are handled here, with custom code that has the