简体   繁体   English

15000个到sql server 2008的连接处于“休眠”状态

[英]15000 connections to sql server 2008 in “sleeping” status

I have set pooling=false in my connection string and i check in my sql server 2008 there is 15000 connection is in sleeping status. 我在连接字符串中设置了pooling=false ,并且在sql server 2008检查是否有15000个连接处于睡眠状态。 I cannot understand why this is happen. 我不明白为什么会这样。 My server is freeze. 我的服务器死机了。 Need some help to resolve it. 需要一些帮助来解决它。 Thanks a lot. 非常感谢。

I assume the reason is that you've set pooling=false . 我认为原因是您已设置pooling=false You should always close the connections in your code best by using the using -statement: 您应该始终using -statement来最好地关闭代码中的连接:

using(var myCon = new SqlConnection("Connection-String"))
{
    myCon.Open();
    // ....
} // will be closed automatically

If you would use Connection-Pooling you could "close" the connection without having the underlying physical connection really being closed. 如果使用连接池,则可以“关闭”连接,而无需真正关闭基础物理连接。 That's managed by the pool. 这是由游泳池管理的。 If you don't use it you have to manage it yourself. 如果不使用它,则必须自己进行管理。 If you don't close connections they will keep sleeping . 如果您不关闭连接,它们将保持睡眠状态

SQL Server Sleeping Status and Connection Pooling SQL Server休眠状态和连接池

Why have you disabled it at all? 为什么根本禁用了它? My advice is: if there is no compelling reason against, enable it again. 我的建议是:如果没有令人信服的理由反对,请再次启用它。

sleeping means it's waiting for its next command from the application or client and in sleep state it isn't using any resources. 睡眠意味着它正在等待来自应用程序或客户端的下一个命令,并且在睡眠状态下它没有使用任何资源。

SQL Server by itself will not kill any connection/process unless the service is initiated for a restart. 除非启动服务以重新启动,否则SQL Server本身不会终止任何连接/进程。

You can do a restart of the SQL Server Service in case you want to start afresh but in production that may not be the option cause it will incur downtime. 如果您想重新启动,但在生产中可能无法执行此操作,这可能会导致停机,因此可以重新restart SQL Server Service

(OR) you can kill those inactive process manually as mentioned by @Remush. (OR)您可以手动kill那些不活动的进程,如@Remush所述。

use sp_who or sp_who2 which will list out the PIDS then use kill PID 使用sp_whosp_who2将列出PIDS然后使用kill PID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM