This commit is contained in:
Christian Schwarz
2024-01-04 13:07:22 +00:00
parent c87c19a646
commit 70f993331c
2 changed files with 24 additions and 28 deletions

View File

@@ -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?;
}
}
}

View File

@@ -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