教义2关闭连接 [英] Doctrine 2 Close Connection

查看:87
本文介绍了教义2关闭连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当压力测试服务器时,mysql会报告大量中止的连接(最多20%)。

>

我正在尝试找到问题。



Mysql手册建议确保与数据库的连接正常关闭。
http://dev.mysql.com/doc/refman/5.0/ en / communication-errors.html



如果教义实际上关闭连接或使用持久连接,我找不到任何信息。



此外,还有其他可以解决中止连接的问题吗?我在这里亏损。



PS。服务器是ubuntu 10.04,nginx 1.x,php 5.3.5(fpm)和mysql 5.1.41

解决方案

我们已经发现了一个问题,在symfony2中启动了单元测试,其中数据库被垃圾邮件连接到睡眠状态。对我们有用的解决方案:

  $ entityManager-> getConnection() - > close(); 


I use doctrine 2 PDO with mysql.

When stress testing the server, mysql reports a lot of aborted connections (up-to 20%).

I am trying to locate the issue.

Mysql manual suggests to ensure that connections to the database are closed properly. http://dev.mysql.com/doc/refman/5.0/en/communication-errors.html

I can't find any information if doctrine actually closes connections or not, or uses persistent connections.

Also, is there anything else that can account for aborted connections? I am at loss here.

PS. Server is ubuntu 10.04, nginx 1.x, php 5.3.5 (fpm) and mysql 5.1.41

解决方案

From what I've observed, Doctrine uses persistent connections.

We've stumbled upon a problem, launching unit tests in symfony2, where the database was spammed with connections in "Sleep" status. The solution that worked for us:

$entityManager->getConnection()->close();

这篇关于教义2关闭连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆