mirror of
https://github.com/neondatabase/neon.git
synced 2026-10-28 22:46:46 +00:00
Rework basebackup.
* add lsn argument * do not expose wait_lsn, wait inside list_nonrels() * fix parameters parsing * expose get_last_record_rlsn() to atomically read (last,prev) pair More work is needed to correctly handle basebackup@old_lsn but current approach already allows to fix test_restart_compute
This commit is contained in:
@@ -7,6 +7,8 @@ use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
use crate::seqwait::MonotonicCounter;
|
||||
|
||||
/// Transaction log block size in bytes
|
||||
pub const XLOG_BLCKSZ: u32 = 8192;
|
||||
|
||||
@@ -197,6 +199,28 @@ impl AtomicLsn {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pair of LSN's pointing to the end of the last valid record and previous one
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct RecordLsn {
|
||||
/// LSN at the end of the current record
|
||||
pub last: Lsn,
|
||||
/// LSN at the end of the previous record
|
||||
pub prev: Lsn,
|
||||
}
|
||||
|
||||
/// Expose `self.last` as counter to be able to use RecordLsn in SeqWait
|
||||
impl MonotonicCounter<Lsn> for RecordLsn {
|
||||
fn cnt_advance(&mut self, lsn: Lsn) {
|
||||
assert!(self.last <= lsn);
|
||||
let new_prev = self.last;
|
||||
self.last = lsn;
|
||||
self.prev = new_prev;
|
||||
}
|
||||
fn cnt_value(&self) -> Lsn {
|
||||
self.last
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user