This commit is contained in:
Bojan Serafimov
2022-05-02 15:36:03 -04:00
parent 68ba6a58a0
commit 9eea3da810
4 changed files with 25 additions and 0 deletions

1
Cargo.lock generated
View File

@@ -1640,6 +1640,7 @@ dependencies = [
"hyper",
"itertools",
"lazy_static",
"libloading",
"metrics",
"nix",
"once_cell",

View File

@@ -62,6 +62,7 @@ postgres_ffi = { path = "../libs/postgres_ffi" }
metrics = { path = "../libs/metrics" }
utils = { path = "../libs/utils" }
workspace_hack = { version = "0.1", path = "../workspace_hack" }
libloading = "0.7.0"
[dev-dependencies]
hex-literal = "0.3"

View File

@@ -0,0 +1,4 @@
fn main() {
pageserver::walredo::linked_redo().unwrap();
}

View File

@@ -163,6 +163,23 @@ pub enum WalRedoError {
InvalidRecord,
}
pub fn linked_redo(
// key: Key,
// lsn: Lsn,
// base_img: Option<Bytes>,
// records: Vec<(Lsn, ZenithWalRecord)>,
) -> Result<Bytes, WalRedoError> {
unsafe {
let pg_path = "/home/bojan/src/neondatabase/neon/tmp_install/bin/postgres";
let pg_lib = libloading::Library::new(pg_path).expect("failed loading pg");
// TODO add stringinfo arg
let apply_record_fn: libloading::Symbol<unsafe extern fn()> =
pg_lib.get(b"ApplyRecord").expect("failed loading ApplyRecord fn");
}
// TODO actually return something
Ok(Bytes::new())
}
///
/// Public interface of WAL redo manager
///
@@ -185,6 +202,8 @@ impl WalRedoManager for PostgresRedoManager {
return Err(WalRedoError::InvalidRequest);
}
// return linked_redo(key, lsn, base_img, records);
let mut img: Option<Bytes> = base_img;
let mut batch_zenith = can_apply_in_zenith(&records[0].1);
let mut batch_start = 0;