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.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
better postgres connection pool management
LazyDBA247-Anyvision7f458d5e78e3
diff --git a/weed/command/scaffold.go b/weed/command/scaffold.goindex f838f77911..993391a42f 100644--- a/weed/command/scaffold.go+++ b/weed/command/scaffold.go@@ -160,6 +160,7 @@ schema = ""sslmode = "disable"connection_max_idle = 100connection_max_open = 100+connection_max_lifetime_seconds = 0[postgres2]enabled = false@@ -181,6 +182,7 @@ schema = ""sslmode = "disable"connection_max_idle = 100connection_max_open = 100+connection_max_lifetime_seconds = 0[cassandra]# CREATE TABLE filemeta (diff --git a/weed/filer/postgres/postgres_store.go b/weed/filer/postgres/postgres_store.goindex 6e0d05315b..75d80e44ae 100644--- a/weed/filer/postgres/postgres_store.go+++ b/weed/filer/postgres/postgres_store.go@@ -3,6 +3,7 @@ package postgresimport ("database/sql""fmt"+ "time""github.com/chrislusf/seaweedfs/weed/filer""github.com/chrislusf/seaweedfs/weed/filer/abstract_sql"@@ -37,10 +38,11 @@ func (store *PostgresStore) Initialize(configuration util.Configuration, prefixconfiguration.GetString(prefix+"sslmode"),configuration.GetInt(prefix+"connection_max_idle"),configuration.GetInt(prefix+"connection_max_open"),+ configuration.GetInt(prefix+"connection_max_lifetime_seconds"),)}-func (store *PostgresStore) initialize(user, password, hostname string, port int, database, schema, sslmode string, maxIdle, maxOpen int) (err error) {+func (store *PostgresStore) initialize(user, password, hostname string, port int, database, schema, sslmode string, maxIdle, maxOpen, maxLifetimeSeconds int) (err error) {store.SupportBucketTable = falsestore.SqlGenerator = &SqlGenPostgres{@@ -71,6 +73,7 @@ func (store *PostgresStore) initialize(user, password, hostname string, port intstore.DB.SetMaxIdleConns(maxIdle)store.DB.SetMaxOpenConns(maxOpen)+ store.DB.SetConnMaxLifetime(time.Duration(maxLifetimeSeconds) * time.Second)if err = store.DB.Ping(); err != nil {return fmt.Errorf("connect to %s error:%v", sqlUrl, err)diff --git a/weed/filer/postgres2/postgres2_store.go b/weed/filer/postgres2/postgres2_store.goindex 94c7604010..44487fd0ec 100644--- a/weed/filer/postgres2/postgres2_store.go+++ b/weed/filer/postgres2/postgres2_store.go@@ -4,6 +4,7 @@ import ("context""database/sql""fmt"+ "time""github.com/chrislusf/seaweedfs/weed/filer""github.com/chrislusf/seaweedfs/weed/filer/abstract_sql"@@ -40,10 +41,11 @@ func (store *PostgresStore2) Initialize(configuration util.Configuration, prefixconfiguration.GetString(prefix+"sslmode"),configuration.GetInt(prefix+"connection_max_idle"),configuration.GetInt(prefix+"connection_max_open"),+ configuration.GetInt(prefix+"connection_max_lifetime_seconds"),)}-func (store *PostgresStore2) initialize(createTable, user, password, hostname string, port int, database, schema, sslmode string, maxIdle, maxOpen int) (err error) {+func (store *PostgresStore2) initialize(createTable, user, password, hostname string, port int, database, schema, sslmode string, maxIdle, maxOpen, maxLifetimeSeconds int) (err error) {store.SupportBucketTable = truestore.SqlGenerator = &postgres.SqlGenPostgres{@@ -74,6 +76,7 @@ func (store *PostgresStore2) initialize(createTable, user, password, hostname ststore.DB.SetMaxIdleConns(maxIdle)store.DB.SetMaxOpenConns(maxOpen)+ store.DB.SetConnMaxLifetime(time.Duration(maxLifetimeSeconds) * time.Second)if err = store.DB.Ping(); err != nil {return fmt.Errorf("connect to %s error:%v", sqlUrl, err)