diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 738fddb..6d5e2e2 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -769,6 +769,7 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.7", + "sled", "smallvec", "smartstring", "sqlite", @@ -1188,6 +1189,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "futures" version = "0.3.28" @@ -2885,6 +2896,22 @@ dependencies = [ "autocfg", ] +[[package]] +name = "sled" +version = "0.34.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f96b4737c2ce5987354855aed3797279def4ebf734436c6aa4552cf8e169935" +dependencies = [ + "crc32fast", + "crossbeam-epoch", + "crossbeam-utils", + "fs2", + "fxhash", + "libc", + "log", + "parking_lot 0.11.2", +] + [[package]] name = "smallvec" version = "1.11.0" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index be69813..cb3ab7b 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -45,7 +45,7 @@ anyhow = "1.0.71" serde_json = "1.0.94" axum-macros = "0.3.8" axum = { version = "0.6.20", features = ["headers", "ws"] } -cozo = { version = "0.7.6", default-features = false, features = ["minimal", "rayon"] } +cozo = { version = "0.7.6", default-features = false, features = ["minimal", "rayon", "storage-sled"] } itertools = "0.11.0" miette = "5.10.0" map-macro = "0.2.6" diff --git a/backend/conf/prod.yaml b/backend/conf/prod.yaml index d13544e..e410005 100644 --- a/backend/conf/prod.yaml +++ b/backend/conf/prod.yaml @@ -6,4 +6,4 @@ host: 0.0.0.0 db: - storage_engine: SQLite \ No newline at end of file + storage_engine: Sled \ No newline at end of file diff --git a/backend/src/conf.rs b/backend/src/conf.rs index adc8a6b..344b17d 100644 --- a/backend/src/conf.rs +++ b/backend/src/conf.rs @@ -43,6 +43,7 @@ pub struct EnvConf { pub enum DbStorageEngine { Memory, SQLite, + Sled, } #[derive(Deserialize, Clone, Debug)] @@ -57,6 +58,7 @@ impl DbConf { match self.storage_engine { DbStorageEngine::Memory => "mem", DbStorageEngine::SQLite => "sqlite", + DbStorageEngine::Sled => "sled", }, &self.path, Default::default(), diff --git a/docs/install/backend-run.txt b/docs/install/backend-run.txt index e651e5a..2057f25 100644 --- a/docs/install/backend-run.txt +++ b/docs/install/backend-run.txt @@ -1,21 +1,10 @@ # local cargo run - # prod test -BE__ENV=prod BE__DB__STORAGE_ENGINE=Memory BE__DB__PATH="" cargo run --release - -# prod (detach process and redirect logs) -BE__ENV=prod \ -BE__DB__STORAGE_ENGINE=Memory \ -BE__DB__PATH="/root/db" \ -nohup cargo run --release > /root/log.txt 2>&1 & - - -# prod test with persistent storage (inconsistent/broken) BE__ENV=prod BE__DB__PATH="/root/db" cargo run --release -# prod with persistent storage (detach process and redirect logs) (inconsistent/broken) +# prod with (detach process and redirect logs) BE__ENV=prod \ BE__DB__PATH="/root/db" \ nohup cargo run --release > /root/log.txt 2>&1 & diff --git a/docs/remember.txt b/docs/remember.txt index 00d0ef3..009a3fd 100644 --- a/docs/remember.txt +++ b/docs/remember.txt @@ -9,9 +9,4 @@ TODO - figure out session "Put session" multiple times per request in logs -- prevent 500 responses due to "database is locked" when SQLite is used - - revert to persistent storage usage for prod -// or/and -- don't just give up - retry 500 from frontend side - - protect endpoint_hits \ No newline at end of file