-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
MySQL client 事务模式下内存问题 #1621
Comments
看起来,是你的姿势有误啊。 如果你的任务都是串行的,一直使用同一个connection就可以了,不用总是disconnect。每个ID是会占用一块资源的,并且程序退出之前不会释放。同一个ID可以用于找回之前那个连接,哪怕WFMySQLConnection对象已经释放了。 如果你无法保证事务之间不会并发,可以简单搞个ID池来解决,不用每次disconnect,相同ID相同URL,就可以复用连接。当然,也可以做成WFMySQLConnection的对象池。 |
感谢回复,请问能否完善事务使用的文档,强调一下需要管理WFMySQLConnection对象的资源,由于姿势错误造成线上内存泄漏挺严重的。 |
好的好的。我记得有大概提了一下。感谢使用。 |
感谢及时的更新。还想请问,如果复用时使用相同的ID但不同的URL初始化,是否会生成新的连接对象?对应的那一小块内存会被复用吗? |
不会,除非两个URL都表示同一个地址,而且用户名,密码,数据库名,字符集什么都完全一样。比如127.0.0.1和localhost,内部可能解析出来就是同一个东西,就找到同一个目标了。
除此之外,ID+url的二元组确定一个通信目标。
其实WFMySQLConnection就是帮助用户实现一个命名事务。你可以看一下实现,完全可以通过自己加一个事务名来解决。就是在URL的query部分加一个transaction=,内部用于区分连接。
…---原始邮件---
发件人: ***@***.***>
发送时间: 2024年9月12日(周四) 晚上8:08
收件人: ***@***.***>;
抄送: ***@***.******@***.***>;
主题: Re: [sogou/workflow] MySQL client 事务模式下内存问题 (Issue #1621)
感谢及时的更新。还想请问,如果复用时使用相同的ID但不同的URL初始化,是否会生成新的连接对象?对应的那一小块内存会被复用吗?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
感谢大佬答疑,我再研究研究 |
参考教程使用事务模式的MySQL client,每次发送新事务会新建一个唯一ID的WFMySQLConnection二级工厂和seriesWork,结束后发送disconnect并回收资源。目前上线后能够正常收发请求且commit或rollback都符合预期,但经过7*24小时监控发现内存使用每天增加,而之前使用非事务模式时从未遇到过该问题。请问是我的使用姿势有误吗?
The text was updated successfully, but these errors were encountered: