Add xlogoff

This commit is contained in:
Bojan Serafimov
2022-05-03 23:40:16 -04:00
parent 8dbd6313e5
commit faa15e32ee
+7 -6
View File
@@ -1,17 +1,18 @@
use std::fs::File;
use anyhow::Result;
use postgres_ffi::waldecoder::WalStreamDecoder;
use postgres_ffi::{pg_constants::WAL_SEGMENT_SIZE, waldecoder::WalStreamDecoder};
use utils::lsn::Lsn;
#[tokio::main]
async fn main() -> Result<()> {
let partial_path = "/home/bojan/tmp/pg_wal/000000010000000000000017";
let startpos = Lsn(0);
let bytes = std::fs::read(partial_path)?;
let partial_path = "/home/bojan/tmp/sk_wal";
let startpos = Lsn(23761464); // I got this by grepping sk log for "restart decoder"
let xlogoff: usize = startpos.segment_offset(WAL_SEGMENT_SIZE);
let mut decoder = WalStreamDecoder::new(startpos);
decoder.feed_bytes(&bytes);
let bytes = std::fs::read(partial_path)?;
decoder.feed_bytes(&bytes[xlogoff..]);
while let Some((lsn, rec)) = decoder.poll_decode()? {
println!("lsn: {}", lsn);
}