improvement: limit db connection max lifetime

This commit is contained in:
Greg Heartsfield 2022-12-17 10:47:35 -06:00
parent 1b2c6f9fca
commit b6e33f044f
2 changed files with 2 additions and 1 deletions

View File

@ -76,6 +76,7 @@ pub fn build_pool(
.test_on_check_out(true) // no noticeable performance hit .test_on_check_out(true) // no noticeable performance hit
.min_idle(Some(min_size)) .min_idle(Some(min_size))
.max_size(max_size) .max_size(max_size)
.max_lifetime(Some(Duration::from_secs(60)))
.build(manager) .build(manager)
.unwrap(); .unwrap();
info!( info!(

View File

@ -637,7 +637,7 @@ async fn nostr_server(
if let Some(previous_query) = running_queries.insert(s.id.to_owned(), abandon_query_tx) { if let Some(previous_query) = running_queries.insert(s.id.to_owned(), abandon_query_tx) {
previous_query.send(()).ok(); previous_query.send(()).ok();
} }
// start a database query // start a database query. this spawns a blocking database query on a worker thread.
db::db_query(s, cid.to_owned(), pool.clone(), query_tx.clone(), abandon_query_rx).await; db::db_query(s, cid.to_owned(), pool.clone(), query_tx.clone(), abandon_query_rx).await;
}, },
Err(e) => { Err(e) => {