设置了连接池参数后,会导致连接用完无法释放 #1834
Labels
No Label
backport/done
backport/v1
blocked
db
oracle
db
sqlserver
duplicate
feature
cache
frontport/done
frontport/main
invalid
kind
breaking
kind
bug
kind
build
kind
dependencies
kind
docs
kind
driver
kind
enhancement
kind
feature
kind
performance
kind
proposal
kind
question
kind
refactor
kind
testing
need
feedback
need
test
proposal:accepted
RaspBerry Pi
regression
skip-changelog
upstream
wip
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#1834
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
xorm版本 xorm.io/xorm v1.0.1
Engine 增加了设置
一开始运行都是很正常的,但是在运行了大概4到5个小时之后会将连接用完,并且无法释放,打印出的db.state()是这样的,可以看到很多的请求处于等待中
You can set MaxLifeTime so that the connection will be closed when idle.
设置了没有用,而且我看了源码,MaxLifeTime 这个参数是当连接闲置的时候才会生效,当所有的连接都是处于inUse状态是不生效的。开始用的时候我也设置了MaxLifeTime这个参数,一样出现这个问题,然后才改成现在的样子,而且不设置 MaxLifeTime 的话,默认的时间是1s,这个应该不会影响
而且现在的连接主要都是处于 inUse 状态,导致无法新建连接,我看了mysql的processlist,发现并没有连接
我在每次sql查询的时候都增加了db的state状态的查询,发现inUse会在某一个时间内直线上升并且,waitCount数量也会增加,而且后面inUse就不会释放了
If you create with
sess := engine.NewSession
, don't forget todefer sess.Close()
.我们所有的调用全部放在transaction里面的,类似这样
You should use
session
if you are in aTransaction
function.哦哦哦 明白了,是我没用对框架,我先把这个改过来,然后再观察观察,感谢感谢,也十分抱歉