We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func query(c context.Context, tdx Tdx, queryStr string, args ...interface{}) (res *sql.Rows, err error) { queryStr = addLimit(queryStr, 0) queryStr, args = changeSQLIn(queryStr, args...) start := time.Now() if res, err = tdx.Query(queryStr, args...); err != nil { return res, err } duration := time.Since(start)
var exp []*Explain if sqlLogger.ShowExplain(duration) { go func() { exp, err := doExplain(tdx, queryStr, args...) if err != nil { return } logPrint(c, sqlLogger, exp, duration, queryStr, args...) }() } logPrint(c, sqlLogger, exp, duration, queryStr, args...) return res, nil
}
query里执行doExplain 这个函数doExplain 应该异步执行或者去掉doExplain逻辑,否则并发query 并发数超过数据库连接池的最大连接数并sqlLogger.ShowExplain(duration) 为ture就很有可能会阻塞死。 为什么会这样呢? tdx.Query ### 获取一个连接还没有释放,你就doExplain又去获取连接。相当于申请一个连接1,再申请连接2,释放连接2,再释放连接1.如果申请连接2的时候连接池已经满了,连接2 申请阻塞,导致连接1释放不了,连接池这种错误用法很典型。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
func query(c context.Context, tdx Tdx, queryStr string, args ...interface{}) (res *sql.Rows, err error) {
queryStr = addLimit(queryStr, 0)
queryStr, args = changeSQLIn(queryStr, args...)
start := time.Now()
if res, err = tdx.Query(queryStr, args...); err != nil {
return res, err
}
duration := time.Since(start)
}
query里执行doExplain 这个函数doExplain 应该异步执行或者去掉doExplain逻辑,否则并发query 并发数超过数据库连接池的最大连接数并sqlLogger.ShowExplain(duration) 为ture就很有可能会阻塞死。
为什么会这样呢?
tdx.Query ### 获取一个连接还没有释放,你就doExplain又去获取连接。相当于申请一个连接1,再申请连接2,释放连接2,再释放连接1.如果申请连接2的时候连接池已经满了,连接2 申请阻塞,导致连接1释放不了,连接池这种错误用法很典型。
The text was updated successfully, but these errors were encountered: