1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 08:20:55 +00:00

Merge pull request #3985 from leapsea/develop

修复多线程下数据库连接异常问题
This commit is contained in:
Ming Deng 2020-06-06 12:40:50 +08:00 committed by GitHub
commit ee615dd08f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -374,6 +374,7 @@ func SetMaxIdleConns(aliasName string, maxIdleConns int) {
func SetMaxOpenConns(aliasName string, maxOpenConns int) { func SetMaxOpenConns(aliasName string, maxOpenConns int) {
al := getDbAlias(aliasName) al := getDbAlias(aliasName)
al.MaxOpenConns = maxOpenConns al.MaxOpenConns = maxOpenConns
al.DB.DB.SetMaxOpenConns(maxOpenConns)
// for tip go 1.2 // for tip go 1.2
if fun := reflect.ValueOf(al.DB).MethodByName("SetMaxOpenConns"); fun.IsValid() { if fun := reflect.ValueOf(al.DB).MethodByName("SetMaxOpenConns"); fun.IsValid() {
fun.Call([]reflect.Value{reflect.ValueOf(maxOpenConns)}) fun.Call([]reflect.Value{reflect.ValueOf(maxOpenConns)})