From 60366dbc1aa59e554f0aef26aca6a7abf8b62c45 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 7 Dec 2025 13:24:03 -0800 Subject: [PATCH] Optimize database connection pool settings for MySQL and PostgreSQL - Reduce connection_max_idle from 100 to 10 (PostgreSQL) and from 2 to 10 (MySQL) - Reduce connection_max_open from 100 to 50 for all database stores - Set connection_max_lifetime_seconds to 300 (5 minutes) to force connection recycling This prevents 'cannot assign requested address' errors under high load by: 1. Limiting the number of concurrent connections to reduce ephemeral port usage 2. Forcing connection recycling to prevent stale connections and port exhaustion 3. Reducing idle connections to minimize resource consumption Fixes #6887 --- weed/command/scaffold/filer.toml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/weed/command/scaffold/filer.toml b/weed/command/scaffold/filer.toml index 9261591c4..1ec91404c 100644 --- a/weed/command/scaffold/filer.toml +++ b/weed/command/scaffold/filer.toml @@ -63,9 +63,9 @@ port = 3306 username = "root" password = "" database = "" # create or use an existing database -connection_max_idle = 2 -connection_max_open = 100 -connection_max_lifetime_seconds = 0 +connection_max_idle = 10 +connection_max_open = 50 +connection_max_lifetime_seconds = 300 interpolateParams = false # if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax: enableUpsert = true @@ -87,9 +87,9 @@ port = 3306 username = "root" password = "" database = "" # create or use an existing database -connection_max_idle = 2 -connection_max_open = 100 -connection_max_lifetime_seconds = 0 +connection_max_idle = 10 +connection_max_open = 50 +connection_max_lifetime_seconds = 300 interpolateParams = false # if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax: enableUpsert = true @@ -117,9 +117,9 @@ sslmode = "disable" # sslkey = "/path/to/client.key" # client private key file # sslrootcert = "/path/to/ca.crt" # CA certificate file # sslcrl = "/path/to/client.crl" # Certificate Revocation List (CRL) (optional) -connection_max_idle = 100 -connection_max_open = 100 -connection_max_lifetime_seconds = 0 +connection_max_idle = 10 +connection_max_open = 50 +connection_max_lifetime_seconds = 300 # Set to true when using PgBouncer connection pooler pgbouncer_compatible = false # if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax: @@ -156,9 +156,9 @@ sslmode = "disable" # sslkey = "/path/to/client.key" # client private key file # sslrootcert = "/path/to/ca.crt" # CA certificate file # sslcrl = "/path/to/client.crl" # Certificate Revocation List (CRL) (optional) -connection_max_idle = 100 -connection_max_open = 100 -connection_max_lifetime_seconds = 0 +connection_max_idle = 10 +connection_max_open = 50 +connection_max_lifetime_seconds = 300 # Set to true when using PgBouncer connection pooler pgbouncer_compatible = false # if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax: