diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2021-01-14 00:04:44 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-14 00:04:44 -0800 |
| commit | ae812c07d6820d483547c471a11cc2df81f342a6 (patch) | |
| tree | 1de3c8cfff2d7b2dddd28ad9863390ef4da97046 /weed/filer/mysql/mysql_store.go | |
| parent | f20743bb383782b0071c0cf0bc8088096321adc6 (diff) | |
| parent | 5581d087021560a4b83cf6434726c00c668abb75 (diff) | |
| download | seaweedfs-ae812c07d6820d483547c471a11cc2df81f342a6.tar.xz seaweedfs-ae812c07d6820d483547c471a11cc2df81f342a6.zip | |
Merge pull request #1743 from LazyDBA247-Anyvision/master
MYSQL - Better Connection Pool Control
Diffstat (limited to 'weed/filer/mysql/mysql_store.go')
| -rw-r--r-- | weed/filer/mysql/mysql_store.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/weed/filer/mysql/mysql_store.go b/weed/filer/mysql/mysql_store.go index 5bc132980..62b9b287a 100644 --- a/weed/filer/mysql/mysql_store.go +++ b/weed/filer/mysql/mysql_store.go @@ -35,12 +35,13 @@ func (store *MysqlStore) Initialize(configuration util.Configuration, prefix str configuration.GetString(prefix+"database"), configuration.GetInt(prefix+"connection_max_idle"), configuration.GetInt(prefix+"connection_max_open"), + configuration.GetInt(prefix+"connection_max_lifetime_seconds"), configuration.GetBool(prefix+"interpolateParams"), ) } -func (store *MysqlStore) initialize(user, password, hostname string, port int, database string, maxIdle, maxOpen int, - interpolateParams bool) (err error) { +func (store *MysqlStore) initialize(user, password, hostname string, port int, database string, maxIdle, maxOpen, + maxLifetimeSeconds int, interpolateParams bool) (err error) { // store.SqlInsert = "INSERT INTO filemeta (dirhash,name,directory,meta) VALUES(?,?,?,?)" store.SqlUpdate = "UPDATE filemeta SET meta=? WHERE dirhash=? AND name=? AND directory=?" @@ -65,6 +66,7 @@ func (store *MysqlStore) initialize(user, password, hostname string, port int, d store.DB.SetMaxIdleConns(maxIdle) store.DB.SetMaxOpenConns(maxOpen) + store.DB.SetConnMaxLifetime(maxLifetimeSeconds*time.Second) if err = store.DB.Ping(); err != nil { return fmt.Errorf("connect to %s error:%v", sqlUrl, err) |
