且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是什么原因导致"内部连接致命错误"

更新时间:2021-10-07 23:44:10

忽略这个问题几个月后,它开始达到一个临界质量交通逐渐增加。在重负载,包括一些爬虫,事情变得疯狂,这些错误在不停浇。

After a few months of ignoring this issue, it started to reach a critical mass as traffic gradually increased. Under heavy load, including some crawlers, things got crazy and these errors poured in nonstop.

经过反复试验,我们终于找到了的SqlCommand或LINQ查询它的SqlConnection不使用后立即关闭了一把。相反,通过一些草率编程从LINQ连接的误解始发,在DataContext物体设置(和连接闭合)仅在一个请求而不是立即的端

Through trial and error, we eventually tracked down a handful of SqlCommand or LINQ queries whose SqlConnection wasn't closed immediately after use. Instead, through some sloppy programming originating from a misunderstanding of LINQ connections, the DataContext objects were disposed (and connections closed) only at the end of a request rather than immediately.

一旦我们重构这些方法立即关闭与C#使用块(释放该池下一个请求)的连接,我们并没有收到更多的错误。虽然我们仍然不知道的根本原因,一个连接池会变得这么混在一起,我们能够停止这种类型的所有错误。这个问题在与其他类似的错误,我张贴一起得到了解决,在这里找到:Why是我的SqlCommand返回一个字符串时,它应该是一个int?

Once we refactored these methods to immediately close the connection with a C# "using" block (freeing up that pool for the next request), we received no more errors. While we still don't know the underlying reason that a connection pool would get so mixed up, we were able to cease all errors of this type. This problem was resolved in conjunction with another similar error I posted, found here: Why is my SqlCommand returning a string when it should be an int?