From 0a886e09ef524f2c0adf4cbabe74fb9ef65132fc Mon Sep 17 00:00:00 2001 From: wendrul <53628737+wendrul@users.noreply.github.com> Date: Sat, 13 Jul 2024 00:18:56 +0200 Subject: [PATCH] Add indexer case to avoid 0 max_database_connection (#4073) --- backend/src/main.rs | 2 +- backend/windmill-common/src/lib.rs | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/backend/src/main.rs b/backend/src/main.rs index cbbb45713a..4328acf5a0 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -259,7 +259,7 @@ async fn windmill_main() -> anyhow::Result<()> { }; tracing::info!("Connecting to database..."); - let db = windmill_common::connect_db(server_mode).await?; + let db = windmill_common::connect_db(server_mode, indexer_mode).await?; tracing::info!("Database connected"); let num_version = sqlx::query_scalar!("SELECT version()").fetch_one(&db).await; diff --git a/backend/windmill-common/src/lib.rs b/backend/windmill-common/src/lib.rs index d4cd97409c..54b143fcac 100644 --- a/backend/windmill-common/src/lib.rs +++ b/backend/windmill-common/src/lib.rs @@ -47,6 +47,7 @@ pub mod tracing_init; pub const DEFAULT_MAX_CONNECTIONS_SERVER: u32 = 50; pub const DEFAULT_MAX_CONNECTIONS_WORKER: u32 = 5; +pub const DEFAULT_MAX_CONNECTIONS_INDEXER: u32 = 5; pub const DEFAULT_HUB_BASE_URL: &str = "https://hub.windmill.dev"; @@ -185,7 +186,10 @@ async fn reset() -> () { todo!() } -pub async fn connect_db(server_mode: bool) -> anyhow::Result> { +pub async fn connect_db( + server_mode: bool, + indexer_mode: bool, +) -> anyhow::Result> { use anyhow::Context; use std::env::var; use tokio::fs::File; @@ -211,12 +215,16 @@ pub async fn connect_db(server_mode: bool) -> anyhow::Result