Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

filer: SQL store pool defaults that survive a concurrent walk (#11110)

Carlos Leyva241541c0266a
diff --git a/weed/command/scaffold/filer.toml b/weed/command/scaffold/filer.toml
index 52df80744c..397b938874 100644
--- a/weed/command/scaffold/filer.toml
+++ b/weed/command/scaffold/filer.toml
@@ -68,7 +68,7 @@ port = 3306
username = "root"
password = ""
database = "" # create or use an existing database
-connection_max_idle = 10
+connection_max_idle = 50
connection_max_open = 50
connection_max_lifetime_seconds = 300
interpolateParams = false
@@ -97,7 +97,7 @@ port = 3306
username = "root"
password = ""
database = "" # create or use an existing database
-connection_max_idle = 10
+connection_max_idle = 50
connection_max_open = 50
connection_max_lifetime_seconds = 300
interpolateParams = false
@@ -127,7 +127,7 @@ 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 = 10
+connection_max_idle = 50
connection_max_open = 50
connection_max_lifetime_seconds = 300
# Set to true when using PgBouncer connection pooler
@@ -166,7 +166,7 @@ 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 = 10
+connection_max_idle = 50
connection_max_open = 50
connection_max_lifetime_seconds = 300
# Set to true when using PgBouncer connection pooler
diff --git a/weed/filer/mysql/mysql_store.go b/weed/filer/mysql/mysql_store.go
index abcef6fe6e..5a7cf9da07 100644
--- a/weed/filer/mysql/mysql_store.go
+++ b/weed/filer/mysql/mysql_store.go
@@ -33,8 +33,12 @@ func (store *MysqlStore) GetName() string {
}
func (store *MysqlStore) Initialize(configuration util.Configuration, prefix string) (err error) {
- // Absent key keeps a pooled default; an explicit 0 disables the idle pool.
- configuration.SetDefault(prefix+"connection_max_idle", 2)
+ // Fewer idle slots than concurrent operations means a fresh connection per
+ // operation, until the filer runs out of ephemeral ports. connection_max_open
+ // stays unset: a listing runs a second query from its own callback, so a
+ // bounded pool deadlocks once the concurrency reaches it.
+ configuration.SetDefault(prefix+"connection_max_idle", 50)
+ configuration.SetDefault(prefix+"connection_max_lifetime_seconds", 300)
// Default on so minimal configs avoid the duplicate-key roundtrip the
// inode-index KvPut would otherwise emit on every write.
configuration.SetDefault(prefix+"enableUpsert", true)
diff --git a/weed/filer/mysql2/mysql2_store.go b/weed/filer/mysql2/mysql2_store.go
index 0783398a3c..e8b0af261d 100644
--- a/weed/filer/mysql2/mysql2_store.go
+++ b/weed/filer/mysql2/mysql2_store.go
@@ -33,8 +33,12 @@ func (store *MysqlStore2) GetName() string {
}
func (store *MysqlStore2) Initialize(configuration util.Configuration, prefix string) (err error) {
- // Absent key keeps a pooled default; an explicit 0 disables the idle pool.
- configuration.SetDefault(prefix+"connection_max_idle", 2)
+ // Fewer idle slots than concurrent operations means a fresh connection per
+ // operation, until the filer runs out of ephemeral ports. connection_max_open
+ // stays unset: a listing runs a second query from its own callback, so a
+ // bounded pool deadlocks once the concurrency reaches it.
+ configuration.SetDefault(prefix+"connection_max_idle", 50)
+ configuration.SetDefault(prefix+"connection_max_lifetime_seconds", 300)
// Default on so minimal configs avoid the duplicate-key roundtrip the
// inode-index KvPut would otherwise emit on every write.
configuration.SetDefault(prefix+"enableUpsert", true)
diff --git a/weed/filer/postgres/postgres_store.go b/weed/filer/postgres/postgres_store.go
index c694f77c39..62f27b327f 100644
--- a/weed/filer/postgres/postgres_store.go
+++ b/weed/filer/postgres/postgres_store.go
@@ -28,8 +28,12 @@ func (store *PostgresStore) GetName() string {
}
func (store *PostgresStore) Initialize(configuration util.Configuration, prefix string) (err error) {
- // Absent key keeps a pooled default; an explicit 0 disables the idle pool.
- configuration.SetDefault(prefix+"connection_max_idle", 2)
+ // Fewer idle slots than concurrent operations means a fresh connection per
+ // operation, until the filer runs out of ephemeral ports. connection_max_open
+ // stays unset: a listing runs a second query from its own callback, so a
+ // bounded pool deadlocks once the concurrency reaches it.
+ configuration.SetDefault(prefix+"connection_max_idle", 50)
+ configuration.SetDefault(prefix+"connection_max_lifetime_seconds", 300)
// Default on so minimal configs are not exposed to duplicate-key tx
// poisoning on Postgres; an explicit false still disables it.
configuration.SetDefault(prefix+"enableUpsert", true)
diff --git a/weed/filer/postgres2/postgres2_store.go b/weed/filer/postgres2/postgres2_store.go
index e846bdf9fe..2eb85764a7 100644
--- a/weed/filer/postgres2/postgres2_store.go
+++ b/weed/filer/postgres2/postgres2_store.go
@@ -33,8 +33,12 @@ func (store *PostgresStore2) GetName() string {
}
func (store *PostgresStore2) Initialize(configuration util.Configuration, prefix string) (err error) {
- // Absent key keeps a pooled default; an explicit 0 disables the idle pool.
- configuration.SetDefault(prefix+"connection_max_idle", 2)
+ // Fewer idle slots than concurrent operations means a fresh connection per
+ // operation, until the filer runs out of ephemeral ports. connection_max_open
+ // stays unset: a listing runs a second query from its own callback, so a
+ // bounded pool deadlocks once the concurrency reaches it.
+ configuration.SetDefault(prefix+"connection_max_idle", 50)
+ configuration.SetDefault(prefix+"connection_max_lifetime_seconds", 300)
// Default on so minimal configs are not exposed to duplicate-key tx
// poisoning on Postgres; an explicit false still disables it.
configuration.SetDefault(prefix+"enableUpsert", true)