Fix maintaining of next multixact

This commit is contained in:
Konstantin Knizhnik
2021-05-24 12:29:14 +03:00
parent e3ea9cf70f
commit 72e373cd4e
3 changed files with 9 additions and 10 deletions

View File

@@ -158,7 +158,6 @@ fn add_pgcontrol_file(
let mut checkpoint = postgres_ffi::decode_checkpoint(checkpoint_bytes)?;
checkpoint.redo = lsn.0;
checkpoint.nextXid.value += 1;
// TODO: When we restart master there are no active transaction and oldestXid is
// equal to nextXid if there are no prepared transactions.
// Let's ignore them for a while...

View File

@@ -574,10 +574,10 @@ pub fn decode_wal_record(checkpoint: &mut CheckPoint, record: Bytes) -> DecodedW
xlogrec.xl_rmid,
xlogrec.xl_info
);
if xlogrec.xl_xid > checkpoint.nextXid.value as u32 {
if xlogrec.xl_xid >= checkpoint.nextXid.value as u32 {
// TODO: handle XID wraparound
checkpoint.nextXid = FullTransactionId {
value: (checkpoint.nextXid.value & 0xFFFFFFFF00000000) | xlogrec.xl_xid as u64,
value: (checkpoint.nextXid.value & 0xFFFFFFFF00000000) | (xlogrec.xl_xid+1) as u64,
};
}
let remaining = xlogrec.xl_tot_len - SizeOfXLogRecord;
@@ -1080,18 +1080,18 @@ pub fn decode_wal_record(checkpoint: &mut CheckPoint, record: Bytes) -> DecodedW
blk.blkno = blkno;
blocks.push(blk);
}
if xlrec.mid > checkpoint.nextMulti {
checkpoint.nextMulti = xlrec.mid;
if xlrec.mid >= checkpoint.nextMulti {
checkpoint.nextMulti = xlrec.mid+1;
}
if xlrec.moff > checkpoint.nextMultiOffset {
checkpoint.nextMultiOffset = xlrec.moff;
if xlrec.moff+xlrec.nmembers > checkpoint.nextMultiOffset {
checkpoint.nextMultiOffset = xlrec.moff+xlrec.nmembers;
}
let max_xid = xlrec
.members
.iter()
.fold(checkpoint.nextXid.value as u32, |acc, mbr| {
if mbr.xid > acc {
mbr.xid
if mbr.xid >= acc {
mbr.xid+1
} else {
acc
}