diff --git a/pageserver/src/walingest.rs b/pageserver/src/walingest.rs index e730ab5e5c..23ab93ccc0 100644 --- a/pageserver/src/walingest.rs +++ b/pageserver/src/walingest.rs @@ -785,21 +785,19 @@ impl WalIngest { } (new, old) => { // Emit one record per VM block that needs updating. - for update in [new, old] { - if let Some((heap_blkno, vm_blk)) = update { - self.put_rel_wal_record( - modification, - vm_rel, - vm_blk, - NeonWalRecord::ClearVisibilityMapFlags { - heap_blkno_1: Some(heap_blkno), - heap_blkno_2: None, - flags, - }, - ctx, - ) - .await?; - } + for (heap_blkno, vm_blk) in [new, old].into_iter().flatten() { + self.put_rel_wal_record( + modification, + vm_rel, + vm_blk, + NeonWalRecord::ClearVisibilityMapFlags { + heap_blkno_1: Some(heap_blkno), + heap_blkno_2: None, + flags, + }, + ctx, + ) + .await?; } } } diff --git a/pageserver/src/walredo.rs b/pageserver/src/walredo.rs index 984b73bc14..a1df1b86e9 100644 --- a/pageserver/src/walredo.rs +++ b/pageserver/src/walredo.rs @@ -414,22 +414,20 @@ impl PostgresRedoManager { "ClearVisibilityMapFlags record on unexpected rel {}", rel ); - for update in [heap_blkno_1, heap_blkno_2] { - if let Some(heap_blkno) = update { - let heap_blkno = *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); - let map_offset = pg_constants::HEAPBLK_TO_OFFSET(heap_blkno); + for heap_blkno in [heap_blkno_1, heap_blkno_2].into_iter().flatten() { + let heap_blkno = *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); + let map_offset = pg_constants::HEAPBLK_TO_OFFSET(heap_blkno); - // Check that we're modifying the correct VM block. - assert!(map_block == blknum); + // Check that we're modifying the correct VM block. + assert!(map_block == blknum); - // equivalent to PageGetContents(page) - let map = &mut page[pg_constants::MAXALIGN_SIZE_OF_PAGE_HEADER_DATA..]; + // equivalent to PageGetContents(page) + let map = &mut page[pg_constants::MAXALIGN_SIZE_OF_PAGE_HEADER_DATA..]; - map[map_byte as usize] &= !(flags << map_offset); - } + map[map_byte as usize] &= !(flags << map_offset); } } // Non-relational WAL records are handled here, with custom code that has the