From c0c84978a93059a2727f942634af5f5ff9ff4050 Mon Sep 17 00:00:00 2001 From: Max Kalashnikoff Date: Wed, 13 Mar 2024 13:48:02 +0100 Subject: [PATCH] fix: increasing Postgres connection pool size --- src/lib.rs | 6 ++++-- tests/context/stores.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f8a160c4..b257c630 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -66,6 +66,8 @@ pub mod state; pub mod stores; pub mod supabase; +const PG_CONNECTION_POOL_SIZE: u32 = 30; + pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Config) -> error::Result<()> { // Check config is valid and then throw the error if its not config.is_valid()?; @@ -76,7 +78,7 @@ pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Config) -> .clone(); let store = PgPoolOptions::new() - .max_connections(5) + .max_connections(PG_CONNECTION_POOL_SIZE) .connect_with(pg_options) .await?; @@ -95,7 +97,7 @@ pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Config) -> .clone(); let tenant_database = PgPoolOptions::new() - .max_connections(5) + .max_connections(PG_CONNECTION_POOL_SIZE) .connect_with(tenant_pg_options) .await?; diff --git a/tests/context/stores.rs b/tests/context/stores.rs index 9764b440..ecfc87c6 100644 --- a/tests/context/stores.rs +++ b/tests/context/stores.rs @@ -7,6 +7,8 @@ use { tracing::log::LevelFilter, }; +const PG_CONNECTION_POOL_SIZE: u32 = 30; + pub async fn open_pg_connections( database_uri: &str, tenant_database_uri: &str, @@ -18,7 +20,7 @@ pub async fn open_pg_connections( .clone(); let pool = PgPoolOptions::new() - .max_connections(5) + .max_connections(PG_CONNECTION_POOL_SIZE) .connect_with(pg_options) .await .expect("failed to connect to postgres"); @@ -35,7 +37,7 @@ pub async fn open_pg_connections( .clone(); let tenant_pool = PgPoolOptions::new() - .max_connections(5) + .max_connections(PG_CONNECTION_POOL_SIZE) .connect_with(tenant_pg_options) .await .expect("failed to connect to postgres");