Skip to content
New issue

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

Fix: Too Many Prepare Statement #4025

Merged
merged 2 commits into from
Jun 23, 2020
Merged

Fix: Too Many Prepare Statement #4025

merged 2 commits into from
Jun 23, 2020

Conversation

jianzhiyao
Copy link
Member

@jianzhiyao jianzhiyao commented Jun 22, 2020

Close #3791
Close #3737
Close #3827

orm/db_alias.go Outdated Show resolved Hide resolved
orm/db_alias.go Outdated Show resolved Hide resolved
orm/db_alias.go Outdated Show resolved Hide resolved
orm/db_alias.go Outdated Show resolved Hide resolved
orm/db_alias.go Outdated Show resolved Hide resolved
orm/db_alias.go Outdated Show resolved Hide resolved
orm/db_alias.go Outdated Show resolved Hide resolved
orm/db_alias.go Outdated Show resolved Hide resolved
@flycash flycash changed the title add garbage recycle for stmt Fix: Too Many Prepare Statement Jun 22, 2020
@flycash flycash merged commit 526a546 into beego:develop Jun 23, 2020
@flycash flycash mentioned this pull request Jun 23, 2020
@lumening
Copy link

更新这个版本后,Prepared_stmt_count 资源未释放问题貌似还没解决

@jianzhiyao
Copy link
Member Author

更新这个版本后,Prepared_stmt_count 资源未释放问题貌似还没解决

服务器几台,beego版本多少

@flycash
Copy link
Collaborator

flycash commented Jul 17, 2020

我们现在设置的上限是,单个orm实例上限是1000。如果你单机存在多个orm实例,又或者是分布式系统部署大量实例,则按照比例相乘则是数量上限。

@lumening
Copy link

beego版本12.2,单机5个go进程使用,两台机器

@jianzhiyao
Copy link
Member Author

beego版本12.2,单机5个go进程使用,两台机器

5 * 2 * 1000 = 10000
按道理没有超过 Mysql 默认的:16382

@lumening
Copy link

beego版本12.2,单机5个go进程使用,两台机器

5 * 2 * 1000 = 10000
按道理没有超过 Mysql 默认的:16382

我将上限调到25000 ,目前已经到了 19319

@jianzhiyao
Copy link
Member Author

beego版本12.2,单机5个go进程使用,两台机器

5 * 2 * 1000 = 10000
按道理没有超过 Mysql 默认的:16382

我将上限调到25000 ,目前已经到了 19319

是否存在多库在同一台 mysql 实例的情况,如果是这样的话,有可能超过限制

@flycash
Copy link
Collaborator

flycash commented Jul 20, 2020

不是算goroutine。是算DB实例。即你创建了多少个DB实例。比如一台机器上创建了n个DB实例,那么上限就是 n * 1000,如果有m台机器,就是m * n * 1000。

@chank
Copy link

chank commented Sep 27, 2020

看代码Beego Prepared Statement是在DB级别Cache的吧,但MySQL Server Prepared Statement的Id生成是在连接级别生成的,不同连接Id会有重复吧,所以是不是应该改为连接级别Cache啊?

https://github.com/mysql/mysql-server/blob/8.0/sql/sql_class.h#L2169

@chank
Copy link

chank commented Sep 27, 2020

而且Beego Raw SQL能不能不用Prepared Statement啊?

@flycash
Copy link
Collaborator

flycash commented Oct 4, 2020

而且Beego Raw SQL能不能不用Prepared Statement啊?

我考虑一下这个问题。

@wakels
Copy link

wakels commented Oct 10, 2020

判断一下sql语句中有没有字符?如果没有就不用Prepared Statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

没有释放prepare Error 1461: Can't create more than max_prepared_stmt_count statements
5 participants