diff --git a/.gitignore b/.gitignore index f40057e543..31c428f9b4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ libsql-sqlite3/**.o.tmp /bindings/c/generated /bindings/c/**.xcframework -/bindings/**/.DS_Store \ No newline at end of file +/bindings/**/.DS_Store +**/.DS_Store \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 1de3584134..344ca898fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,9 +363,9 @@ dependencies = [ [[package]] name = "aws-credential-types" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16838e6c9e12125face1c1eff1343c75e3ff540de98ff7ebd61874a89bcfeb9" +checksum = "60e8f6b615cb5fc60a98132268508ad104310f0cfb25a1c22eee76efdf9154da" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", @@ -375,15 +375,16 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.3.1" +version = "1.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c5f920ffd1e0526ec9e70e50bf444db50b204395a0fa7016bbf9e31ea1698f" +checksum = "b5ac934720fbb46206292d2c75b57e67acfc56fe7dfd34fb9a02334af08409ea" dependencies = [ "aws-credential-types", "aws-sigv4", "aws-smithy-async", "aws-smithy-eventstream", "aws-smithy-http", + "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", "aws-types", @@ -391,6 +392,7 @@ dependencies = [ "fastrand", "http 0.2.12", "http-body 0.4.6", + "once_cell", "percent-encoding", "pin-project-lite", "tracing", @@ -399,11 +401,10 @@ dependencies = [ [[package]] name = "aws-sdk-s3" -version = "1.40.0" +version = "1.62.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8367c403fdf27690684b926a46ed9524099a69dd5dfcef62028bf4096b5b809f" +checksum = "83d3a2854c7490b4c63d2b0e8c3976d628c80afa3045d078a715b2edb2ee4e0a" dependencies = [ - "ahash", "aws-credential-types", "aws-runtime", "aws-sigv4", @@ -501,9 +502,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.3" +version = "1.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5df1b0fa6be58efe9d4ccc257df0a53b89cd8909e86591a13ca54817c87517be" +checksum = "9bfe75fad52793ce6dec0dc3d4b1f388f038b5eb866c8d4d7f3a8e21b5ea5051" dependencies = [ "aws-credential-types", "aws-smithy-eventstream", @@ -541,9 +542,9 @@ dependencies = [ [[package]] name = "aws-smithy-checksums" -version = "0.60.11" +version = "0.60.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c4134cf3adaeacff34d588dbe814200357b0c466d730cf1c0d8054384a2de4" +checksum = "ba1a71073fca26775c8b5189175ea8863afb1c9ea2cceb02a5de5ad9dfbaa795" dependencies = [ "aws-smithy-http", "aws-smithy-types", @@ -562,9 +563,9 @@ dependencies = [ [[package]] name = "aws-smithy-eventstream" -version = "0.60.4" +version = "0.60.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6363078f927f612b970edf9d1903ef5cef9a64d1e8423525ebb1f0a1633c858" +checksum = "461e5e02f9864cba17cff30f007c2e37ade94d01e87cdb5204e44a84e6d38c17" dependencies = [ "aws-smithy-types", "bytes", @@ -573,9 +574,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.60.9" +version = "0.60.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9cd0ae3d97daa0a2bf377a4d8e8e1362cae590c4a1aad0d40058ebca18eb91e" +checksum = "7809c27ad8da6a6a68c454e651d4962479e81472aa19ae99e59f9aba1f9713cc" dependencies = [ "aws-smithy-eventstream", "aws-smithy-runtime-api", @@ -613,9 +614,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.6.2" +version = "1.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce87155eba55e11768b8c1afa607f3e864ae82f03caf63258b37455b0ad02537" +checksum = "9f20685047ca9d6f17b994a07f629c813f08b5bce65523e47124879e60103d45" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -640,9 +641,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.7.1" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30819352ed0a04ecf6a2f3477e344d2d1ba33d43e0f09ad9047c12e0d923616f" +checksum = "92165296a47a812b267b4f41032ff8069ab7ff783696d217f0994a0d7ab585cd" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -657,9 +658,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.0" +version = "1.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe321a6b21f5d8eabd0ade9c55d3d0335f3c3157fc2b3e87f05f34b539e4df5" +checksum = "c7b8a53819e42f10d0821f56da995e1470b199686a1809168db6ca485665f042" dependencies = [ "base64-simd", "bytes", @@ -683,9 +684,9 @@ dependencies = [ [[package]] name = "aws-smithy-xml" -version = "0.60.8" +version = "0.60.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d123fbc2a4adc3c301652ba8e149bf4bc1d1725affb9784eb20c953ace06bf55" +checksum = "3db87b96cb1b16c024980f133968d52882ca0daaee3a086c6decc500f6c99728" dependencies = [ "xmlparser", ] @@ -2863,9 +2864,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libloading" @@ -3413,13 +3414,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.11" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -4755,7 +4756,6 @@ version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ - "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -5234,22 +5234,21 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", "tracing", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -5264,9 +5263,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", @@ -6401,6 +6400,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" diff --git a/bottomless-cli/Cargo.toml b/bottomless-cli/Cargo.toml index 264611b748..d57eba3afe 100644 --- a/bottomless-cli/Cargo.toml +++ b/bottomless-cli/Cargo.toml @@ -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" diff --git a/bottomless/Cargo.toml b/bottomless/Cargo.toml index 59e5cb5dfa..7020db7129 100644 --- a/bottomless/Cargo.toml +++ b/bottomless/Cargo.toml @@ -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" } diff --git a/libsql-server/Cargo.toml b/libsql-server/Cargo.toml index 9dea0ef2a1..0257c184bf 100644 --- a/libsql-server/Cargo.toml +++ b/libsql-server/Cargo.toml @@ -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" @@ -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"] } @@ -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" diff --git a/libsql-sys/src/wal/ffi.rs b/libsql-sys/src/wal/ffi.rs index fd3044665a..94b63389a4 100644 --- a/libsql-sys/src/wal/ffi.rs +++ b/libsql-sys/src/wal/ffi.rs @@ -446,8 +446,8 @@ pub unsafe extern "C" fn checkpoint( _ => 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, diff --git a/libsql/src/database.rs b/libsql/src/database.rs index b4da6171bf..72484a1fcb 100644 --- a/libsql/src/database.rs +++ b/libsql/src/database.rs @@ -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()?;