请问如果仍然对它们的引用合并SQL连接被清理? [英] Will pooled SQL Connections be scavenged if there is still a reference to them?

查看:151
本文介绍了请问如果仍然对它们的引用合并SQL连接被清理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@usr 和我的在另外的一个有关.NET是否会清除已空闲打开的连接,但仍保持保持的基准问题上的分歧。

@usr and I are having a disagreement in another question about whether or not .NET will scavenge open connections that have been idle, but still maintain a held reference.

我维护,一>,如果物理连接是闲置了一段时间,这将是一个为期即使的SQLConnection 的对象引用保持举行时间后回收。

I maintain, based on documentation, that if the physical connection is idle for a period of time, it will be reclaimed after a period of time even if a SQLConnection object reference remains held.

USR声称,这不会发生,而且只回收不再有引用连接。他断言,因为这会使连接池不可靠的,并会造成严重破坏的交易。

usr claims that this won't happen, and it only reclaims connections that no longer have references. His assertion as this would make connection pooling unreliable and would cause havoc with transactions.

我会承认,该文件是含糊举行引用的问题。

I will admit, the documentation is vague about the issue of held references.

我在寻找在这一个权威的答案,而不仅仅是猜测。要么有人尝试和验证这两种情况下,还是有人用的内部工作的知识。

I'm looking for an authoritative answer on this, not just guessing. Either someone has experimented and proven either case, or someone with knowledge of the internal workings.

那么,哪一个是什么呢?

So which one is it?

编辑:

我觉得这里的混乱是与封闭的术语。这似乎是此案的文件指的是关闭的删除的从池中连接的物理连接。而合指的是释放开物理连接放回池中供再次使用。

I think the confusion here is with the terminology of "Closed". What appears to be the case is that the documentation refers to closing the physical connection as "Removing" the connection from the pool. While "Closing" refers to releasing the open physical connection back into the pool for re-use.

打开的连接仍然可以终止,但目前还不清楚,如果波尔标志着这是无效的,如果它仍然持有开放的客户端应用程序(即客户端应用程序还没有叫收盘时中止连接)不知道它真正虽然重要,比为池数量的部分除外。

Open connections can still be aborted, but it's unclear if the pooler marks this as invalid if it's still held as open by the client app (ie client app has not yet called close on the aborted connection) Not sure it really matters though, other than as part of the pool count.

推荐答案

我可以告诉你100%的把握,连接的返回到池中,直到释放。我有一个会话创建一个临时表,离开它,而等待用户输入挂。用户6分钟后回来,presses一个按钮,它不断的同的 SPID 并生活在继续对临时表。

I can tell you with 100% certainty that the connection DOES NOT return to the pool until released. I had a session create a temporary table, and left it hanging while waiting for user input. The user comes back after 6 minutes, presses a button and it continues on the same SPID and life goes on against the temporary table.

应用逻辑,这是有道理的,因为你可以想像的严重破坏,如果你失去了SPID只是因为你已经空闲了X分钟?如果你一直有以平的SQL Server的命令,只是为了保持它活着? (这将是疯狂的的)

Applying logic, it makes sense because can you imagine the havoc if you lose the SPID just because you've been idle for X minutes? Should you keep having to "ping" SQL Server with a command just to keep it alive? (it would be insane)


你似乎是混淆2概念。当连接被关闭时,它返回到池中。如果超出范围,则隐含地关闭 - >返回到池中。为闲置的引用是指当池中连接空闲,而不是它主动地引用时和没有关闭的。 A举行的连接,甚至没有在游泳池有资格获得任何类型的清除的。从池中释放资源是有道理的,因为一个网络应用程序可以很容易爆连接100秒,然后在接下来的几个月里保持在大约20左右,活跃的并发连接。


You appear to be confusing 2 concepts. When a Connection is closed, it returns to the pool. If it goes out of scope, it is implicitly closed -> returns to the pool. The reference to "idle" refers to when the connection in the pool becomes idle, not when it's actively referenced and not closed. A held connection isn't even in the pool to become eligible for any type of scavenging. Freeing resources from the pool makes sense, because a web-app can easily burst to 100s of connections, then for the next few months stay at around 20 or so active concurrent connections.

这篇关于请问如果仍然对它们的引用合并SQL连接被清理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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