Skip to content

Commit 8ac523d

Browse files
knizhnikKonstantin Knizhnik
and
Konstantin Knizhnik
authored
Do not assign page LSN to new (uninitialized) page in ClearVisibilityMapFlags redo handler (#9287)
## Problem https://neondb.slack.com/archives/C04DGM6SMTM/p1727872045252899 See #9240 ## Summary of changes Add `!page_is_new` check before assigning page lsn. ## Checklist before requesting a review - [ ] I have performed a self-review of my code. - [ ] If it is a core feature, I have added thorough tests. - [ ] Do we need to implement analytics? if so did you add the relevant metrics to the dashboard? - [ ] If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section. ## Checklist before merging - [ ] Do not forget to reformat commit message to not include the above checklist --------- Co-authored-by: Konstantin Knizhnik <[email protected]>
1 parent 3c16bd6 commit 8ac523d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pageserver/src/walredo/apply_neon.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ pub(crate) fn apply_in_neon(
6767
let map = &mut page[pg_constants::MAXALIGN_SIZE_OF_PAGE_HEADER_DATA..];
6868

6969
map[map_byte as usize] &= !(flags << map_offset);
70-
postgres_ffi::page_set_lsn(page, lsn);
70+
// The page should never be empty, but we're checking it anyway as a precaution, so that if it is empty for some reason anyway, we don't make matters worse by setting the LSN on it.
71+
if !postgres_ffi::page_is_new(page) {
72+
postgres_ffi::page_set_lsn(page, lsn);
73+
}
7174
}
7275

7376
// Repeat for 'old_heap_blkno', if any
@@ -81,7 +84,10 @@ pub(crate) fn apply_in_neon(
8184
let map = &mut page[pg_constants::MAXALIGN_SIZE_OF_PAGE_HEADER_DATA..];
8285

8386
map[map_byte as usize] &= !(flags << map_offset);
84-
postgres_ffi::page_set_lsn(page, lsn);
87+
// The page should never be empty, but we're checking it anyway as a precaution, so that if it is empty for some reason anyway, we don't make matters worse by setting the LSN on it.
88+
if !postgres_ffi::page_is_new(page) {
89+
postgres_ffi::page_set_lsn(page, lsn);
90+
}
8591
}
8692
}
8793
// Non-relational WAL records are handled here, with custom code that has the

0 commit comments

Comments
 (0)