Skip to content

Commit

Permalink
Generate a random name for in-memory database
Browse files Browse the repository at this point in the history
  • Loading branch information
adzialocha committed Nov 16, 2023
1 parent 86687b7 commit 07a6834
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions aquadoggo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ libp2p = "0.52.0"
log = "0.4.20"
p2panda-rs = "0.8.0"
path-clean = "1.0.1"
rand = "0.8.5"
serde = { version = "1.0.185", features = ["serde_derive"] }
tempfile = "3.7.0"
tokio = { version = "1.28.2", features = ["full"] }
Expand Down
9 changes: 8 additions & 1 deletion aquadoggo_cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,17 @@ pub struct Configuration {

impl Default for Configuration {
fn default() -> Self {
// Give each in-memory SQLite database an unique name as we're observing funny issues with
// SQLite sharing data between processes (!) and breaking each others databases
// potentially.
//
// See related issue: https://github.com/p2panda/aquadoggo/issues/568
let db_name = format!("dbmem{}", rand::random::<u32>());

Self {
log_level: "off".into(),
allow_schema_ids: UncheckedAllowList::Wildcard,
database_url: "sqlite::memory:".into(),
database_url: format!("sqlite://{db_name}?mode=memory&cache=private"),
database_max_connections: 32,
http_port: 2020,
quic_port: 2022,
Expand Down

0 comments on commit 07a6834

Please sign in to comment.