Compare commits

...

2 Commits

Author SHA1 Message Date
Bojan Serafimov
4c0534f85e WIP 2022-05-03 13:13:36 -04:00
Bojan Serafimov
9eea3da810 WIP 2022-05-02 15:36:03 -04:00
6 changed files with 53 additions and 0 deletions

5
Cargo.lock generated
View File

@@ -1640,6 +1640,7 @@ dependencies = [
"hyper",
"itertools",
"lazy_static",
"libloading",
"metrics",
"nix",
"once_cell",
@@ -2148,6 +2149,10 @@ dependencies = [
"yasna",
]
[[package]]
name = "redo"
version = "0.1.0"
[[package]]
name = "redox_syscall"
version = "0.2.10"

8
libs/redo/Cargo.toml Normal file
View File

@@ -0,0 +1,8 @@
[package]
name = "redo"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

16
libs/redo/src/main.rs Normal file
View File

@@ -0,0 +1,16 @@
// This will look for `int redo()` in `libredo.a`
#[link(name = "redo")]
extern "C" {
fn redo() -> i32;
}
// To compile this, run:
// rustc libs/redo/src/main.rs -L /home/bojan/src/neondatabase/neon/tmp_install/lib/
fn main() {
unsafe {
dbg!(redo());
}
}

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;