Skip to content

Commit

Permalink
Show more debug on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
crodas committed Mar 1, 2025
1 parent 871c78e commit 2827cc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
27 changes: 9 additions & 18 deletions crates/cdk-sqlite/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,26 @@ use std::str::FromStr;
use std::time::Duration;

use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
use sqlx::{Error, Executor, Pool, Sqlite};
use sqlx::{Error, Pool, Sqlite};

#[inline(always)]
pub async fn create_sqlite_pool(path: &str) -> Result<Pool<Sqlite>, Error> {
let db_options = SqliteConnectOptions::from_str(path)?
.busy_timeout(Duration::from_secs(10))
.read_only(false)
.pragma("busy_timeout", "5000")
.pragma("journal_mode", "wal")
.pragma("synchronous", "normal")
.pragma("temp_store", "memory")
.pragma("mmap_size", "30000000000")
.shared_cache(true)
.create_if_missing(true);

let pool = SqlitePoolOptions::new()
.min_connections(1)
.max_connections(1)
.before_acquire(|conn, _meta| {
Box::pin(async move {
// Info: https://phiresky.github.io/blog/2020/sqlite-performance-tuning/
conn.execute(
r#"
PRAGMA busy_timeout = 5000;
PRAGMA journal_mode = wal;
PRAGMA synchronous = normal;
PRAGMA temp_store = memory;
PRAGMA mmap_size = 30000000000;
"#,
)
.await?;

Ok(true)
})
})
.idle_timeout(None)
.max_lifetime(None)
.connect_with(db_options)
.await?;

Expand Down
3 changes: 1 addition & 2 deletions misc/itests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,14 @@ echo "Starting regtest mint"
# cargo run --bin regtest_mint &

export CDK_MINTD_CLN_RPC_PATH="$cdk_itests/cln/one/regtest/lightning-rpc";


export CDK_MINTD_URL="http://$cdk_itests_mint_addr:$cdk_itests_mint_port_0";
export CDK_MINTD_WORK_DIR="$cdk_itests";
export CDK_MINTD_LISTEN_HOST=$cdk_itests_mint_addr;
export CDK_MINTD_LISTEN_PORT=$cdk_itests_mint_port_0;
export CDK_MINTD_LN_BACKEND="cln";
export CDK_MINTD_MNEMONIC="eye survey guilt napkin crystal cup whisper salt luggage manage unveil loyal";
export CDK_MINTD_DATABASE=$MINT_DATABASE;
export RUST_BACKTRACE=1

echo "Starting cln mintd";
cargo run --bin cdk-mintd &
Expand Down

0 comments on commit 2827cc4

Please sign in to comment.