From 863f8dcca3efce87a29853f6c842f85de594019e Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Sat, 11 Feb 2023 01:42:14 -0700 Subject: [PATCH] Revert "server: Allow configuring max database connections" Causes issues with SQLite. To be investigated further. This reverts commit 9fdec3397d013a1e60d674550233ff073db27540. --- server/src/config.rs | 8 -------- server/src/lib.rs | 8 ++------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/server/src/config.rs b/server/src/config.rs index 7967c7e..5ee6f51 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -129,10 +129,6 @@ pub struct DatabaseConfig { /// If enabled, a heartbeat query will be sent every minute. #[serde(default = "default_db_heartbeat")] pub heartbeat: bool, - - /// The maximum number of concurrent connections to maintain. - #[serde(default = "default_db_max_connections")] - pub max_connections: u32, } /// File storage configuration. @@ -319,10 +315,6 @@ fn default_db_heartbeat() -> bool { false } -fn default_db_max_connections() -> u32 { - 20 -} - fn default_soft_delete_caches() -> bool { false } diff --git a/server/src/lib.rs b/server/src/lib.rs index 1109f89..38d3b1a 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -37,7 +37,7 @@ use axum::{ http::{uri::Scheme, Uri}, Router, }; -use sea_orm::{query::Statement, ConnectionTrait, ConnectOptions, Database, DatabaseConnection}; +use sea_orm::{query::Statement, ConnectionTrait, Database, DatabaseConnection}; use tokio::sync::OnceCell; use tokio::time; use tower_http::catch_panic::CatchPanicLayer; @@ -105,11 +105,7 @@ impl StateInner { async fn database(&self) -> ServerResult<&DatabaseConnection> { self.database .get_or_try_init(|| async { - let options = ConnectOptions::new(self.config.database.url.to_owned()) - .max_connections(self.config.database.max_connections) - .to_owned(); - - Database::connect(options) + Database::connect(&self.config.database.url) .await .map_err(ServerError::database_error) })