Skip to content

Commit

Permalink
Fix advance of multixact offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Knizhnik committed Feb 1, 2024
1 parent b2da246 commit 68e0a63
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pageserver/src/walingest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,14 +1355,19 @@ impl WalIngest {
// Note: The multixact members can wrap around, even within one WAL record.
offset = offset.wrapping_add(n_this_page as u32);
}
// Advance `nextMulti` in wraparound-aware way. This should match the MultiXactAdvanceNextMXact()
// logic in PostgreSQL's xlog_redo() function.
if xlrec.mid.wrapping_sub(self.checkpoint.nextMulti) as i32 >= 0 {
let next_mid =
std::cmp::max(xlrec.mid.wrapping_add(1), pg_constants::FIRST_MULTIXACT_ID);
self.checkpoint.nextMulti = next_mid;
self.checkpoint_modified = true;
}
if xlrec.moff + xlrec.nmembers > self.checkpoint.nextMultiOffset {
self.checkpoint.nextMultiOffset = xlrec.moff + xlrec.nmembers;
if (xlrec.moff.wrapping_add(xlrec.nmembers)).wrapping_sub(self.checkpoint.nextMultiOffset)
as i32
>= 0
{
self.checkpoint.nextMultiOffset = xlrec.moff.wrapping_add(xlrec.nmembers);
self.checkpoint_modified = true;
}
let max_mbr_xid = xlrec.members.iter().fold(None, |acc, mbr| {
Expand Down

0 comments on commit 68e0a63

Please sign in to comment.