Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

bottomless: add read-only replicas that read from S3 #324

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion bottomless-cli/src/replicator_extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,33 @@ impl Replicator {
);
}
Err(aws_sdk_s3::types::SdkError::ServiceError(err)) if err.err().is_no_such_key() => {
println!("\tno main database snapshot file found")
match self
.client
.get_object_attributes()
.bucket(&self.bucket)
.key(format!("{}-{}/db.gz", self.db_name, generation))
.object_attributes(aws_sdk_s3::model::ObjectAttributes::ObjectSize)
.send()
.await {
Ok(attrs) => {
println!("\tmain database snapshot:");
println!("\t\tobject size: {}", attrs.object_size());
println!(
"\t\tlast modified: {}",
attrs
.last_modified()
.map(|s| s
.fmt(aws_smithy_types::date_time::Format::DateTime)
.unwrap_or_else(|e| e.to_string()))
.as_deref()
.unwrap_or("never")
);
}
Err(aws_sdk_s3::types::SdkError::ServiceError(err)) if err.err().is_no_such_key() => {
println!("\tmain database snapshot: not found");
}
Err(e) => println!("\tfailed to fetch main database snapshot info: {e}"),
}
}
Err(e) => println!("\tfailed to fetch main database snapshot info: {e}"),
};
Expand Down
2 changes: 2 additions & 0 deletions bottomless/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ anyhow = "1.0.66"
async-compression = { version = "0.3.15", features = ["tokio", "gzip"] }
aws-config = { version = "0.52.0" }
aws-sdk-s3 = { version = "0.22.0" }
byteorder = "1.4.3"
bytes = "1"
crc = "3.0.0"
futures = { version = "0.3.25" }
Expand All @@ -24,6 +25,7 @@ uuid = { version = "1.3", features = ["v7"] }

[features]
libsql_linked_statically = []
init_tracing_statically = []

[lib]
crate-type = ["rlib", "staticlib"]
4 changes: 2 additions & 2 deletions bottomless/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
all: debug

debug: bottomless.c src/lib.rs
cargo build -p bottomless && clang -Wall -fPIC -shared -DLIBSQL_ENABLE_BOTTOMLESS_WAL bottomless.c -I${LIBSQL_DIR} ../target/debug/libbottomless.a -o ../target/debug/bottomless.so
cargo build -p bottomless -Finit_tracing_statically && clang -Wall -fPIC -shared -DLIBSQL_ENABLE_BOTTOMLESS_WAL bottomless.c -I${LIBSQL_DIR} ../target/debug/libbottomless.a -o ../target/debug/bottomless.so

release: bottomless.c src/lib.rs
cargo build -p bottomless -j1 --quiet --release && \
cargo build -p bottomless -Finit_tracing_statically -j1 --quiet --release && \
clang -fPIC -shared -DLIBSQL_ENABLE_BOTTOMLESS_WAL bottomless.c -I${LIBSQL_DIR} ../target/release/libbottomless.a \
-o ../target/release/bottomless.so

Expand Down
5 changes: 3 additions & 2 deletions bottomless/src/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub use sqld_libsql_bindings::ffi::{
libsql_wal_methods, sqlite3, sqlite3_file, sqlite3_vfs, PageHdrIter, PgHdr, Wal, WalIndexHdr,
SQLITE_CANTOPEN, SQLITE_CHECKPOINT_TRUNCATE, SQLITE_IOERR_WRITE, SQLITE_OK,
libsql_wal, libsql_wal_methods, sqlite3, sqlite3_file, sqlite3_vfs, PageHdrIter, PgHdr, Wal,
WalIndexHdr, SQLITE_CANTOPEN, SQLITE_CHECKPOINT_TRUNCATE, SQLITE_IOERR_READ,
SQLITE_IOERR_WRITE, SQLITE_OK, SQLITE_READONLY,
};

#[repr(C)]
Expand Down
Loading