From 07a6834e586924989b4efb722b18b8e7e57c6c56 Mon Sep 17 00:00:00 2001 From: adz Date: Thu, 16 Nov 2023 21:31:55 +0100 Subject: [PATCH] Generate a random name for in-memory database --- Cargo.lock | 1 + aquadoggo_cli/Cargo.toml | 1 + aquadoggo_cli/src/config.rs | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index e009da559..54800b2b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,6 +226,7 @@ dependencies = [ "log", "p2panda-rs", "path-clean", + "rand 0.8.5", "serde", "tempfile", "tokio", diff --git a/aquadoggo_cli/Cargo.toml b/aquadoggo_cli/Cargo.toml index c91196aa2..ed1681e41 100644 --- a/aquadoggo_cli/Cargo.toml +++ b/aquadoggo_cli/Cargo.toml @@ -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"] } diff --git a/aquadoggo_cli/src/config.rs b/aquadoggo_cli/src/config.rs index 6ebfada05..dd1aa8300 100644 --- a/aquadoggo_cli/src/config.rs +++ b/aquadoggo_cli/src/config.rs @@ -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::()); + 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,