Skip to content

Commit

Permalink
change storage engine to sled from sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
phantie committed Apr 30, 2024
1 parent 73ffc2c commit 69cd485
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 19 deletions.
27 changes: 27 additions & 0 deletions backend/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 backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion backend/conf/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
host: 0.0.0.0

db:
storage_engine: SQLite
storage_engine: Sled
2 changes: 2 additions & 0 deletions backend/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub struct EnvConf {
pub enum DbStorageEngine {
Memory,
SQLite,
Sled,
}

#[derive(Deserialize, Clone, Debug)]
Expand All @@ -57,6 +58,7 @@ impl DbConf {
match self.storage_engine {
DbStorageEngine::Memory => "mem",
DbStorageEngine::SQLite => "sqlite",
DbStorageEngine::Sled => "sled",
},
&self.path,
Default::default(),
Expand Down
13 changes: 1 addition & 12 deletions docs/install/backend-run.txt
Original file line number Diff line number Diff line change
@@ -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 &
Expand Down
5 changes: 0 additions & 5 deletions docs/remember.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 69cd485

Please sign in to comment.