Skip to content
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ libsql-sqlite3/**.o.tmp

/bindings/c/generated
/bindings/c/**.xcframework
/bindings/**/.DS_Store
/bindings/**/.DS_Store
**/.DS_Store
78 changes: 43 additions & 35 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion bottomless-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description = "Command-line interface for bottomless replication for libSQL"
anyhow = "1.0.66"
async-compression = { version = "0.4.4", features = ["tokio", "gzip", "zstd"] }
aws-config = "1"
aws-sdk-s3 = "1"
aws-sdk-s3 = "=1.62"
aws-smithy-types = "1"
bottomless = { version = "0", path = "../bottomless" }
bytes = "1"
Expand Down
2 changes: 1 addition & 1 deletion bottomless/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description = "Bottomless replication for libSQL"
anyhow = "1.0.66"
async-compression = { version = "0.4.4", features = ["tokio", "gzip", "zstd"] }
aws-config = { version = "1" }
aws-sdk-s3 = { version = "1" }
aws-sdk-s3 = { version = "=1.62" }
bytes = "1"
libsql-sys = { path = "../libsql-sys" }
libsql_replication = { path = "../libsql-replication" }
Expand Down
18 changes: 5 additions & 13 deletions libsql-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ rustls = "0.21.7"
rustls-pemfile = "1.0.3"
semver = "1.0.18"
serde = { version = "1.0.149", features = ["derive", "rc"] }
serde_json = { version = "1.0.91", features = ["preserve_order"] }
# serde_json = { version = "1.0.91", features = ["preserve_order"] }
serde_json = { version = "1.0.91" }

md-5 = "0.10"
sha2 = "0.10"
sha256 = "1.1.3"
Expand All @@ -79,17 +81,7 @@ sqlite3-parser = { package = "libsql-sqlite3-parser", path = "../vendored/sqlite
] }
tempfile = "3.7.0"
thiserror = "1.0.38"
tokio = { version = "1.43", features = [
"rt-multi-thread",
"net",
"io-std",
"io-util",
"time",
"macros",
"sync",
"fs",
"signal",
] }
tokio = { version = "1.43", features = ["rt-multi-thread", "net", "io-std", "io-util", "time", "macros", "sync", "fs", "signal"] }
tokio-stream = { version = "0.1.11", features = ["sync"] }
tokio-tungstenite = "0.20"
tokio-util = { version = "0.7.8", features = ["io", "io-util"] }
Expand Down Expand Up @@ -119,7 +111,7 @@ rheaper = { git = "https://github.com/MarinPostma/rheaper.git", tag = "v0.2.0",
] }
tar = "0.4.41"
aws-config = { version = "1", features = ["behavior-version-latest"] }
aws-sdk-s3 = "1"
aws-sdk-s3 = "=1.62"
aws-smithy-runtime = "1.6.2"
dialoguer = { version = "0.11.0", features = ["history"] }
indicatif = "0.17.8"
Expand Down
4 changes: 2 additions & 2 deletions libsql-sys/src/wal/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ pub unsafe extern "C" fn checkpoint<T: Wal>(
_ => panic!("invalid checkpoint mode"),
};

let in_wal = (!frames_in_wal_out.is_null()).then(|| &mut *frames_in_wal_out);
let backfilled = (!checkpointed_frames_out.is_null()).then(|| &mut *checkpointed_frames_out);
let in_wal = frames_in_wal_out.as_mut();
let backfilled = checkpointed_frames_out.as_mut();
let mut db = Sqlite3Db { inner: db };
match this.checkpoint(
&mut db,
Expand Down
32 changes: 20 additions & 12 deletions libsql/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,18 +689,26 @@ impl Database {
hrana::connection::HttpConnection, local::impls::LibsqlConnection,
replication::connection::State, sync::connection::SyncedConnection,
};
use tokio::sync::Mutex;

tokio::task::block_in_place(move || {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
rt.block_on(async {
db.bootstrap_db().await?;
Ok::<(), crate::Error>(())
})
})?;
use tokio::{runtime::RuntimeFlavor, sync::Mutex};

match tokio::runtime::Handle::current().runtime_flavor() {
RuntimeFlavor::CurrentThread => {
// synchronous wait on current-thread runtime
let sync_ctx_clone = db.sync_ctx.clone();
tokio::spawn(async move {
loop {
let mut sync_ctx = sync_ctx_clone.as_ref().unwrap().lock().await;
crate::sync::bootstrap_db(&mut sync_ctx).await.ok();
}
});
}
RuntimeFlavor::MultiThread => {
tokio::task::block_in_place(move || {
tokio::runtime::Handle::current().block_on(db.bootstrap_db()).ok();
});
}
_ => unreachable!("only current-thread and multi-thread runtimes are supported"),
}

let local = db.connect()?;

Expand Down