过去两天我一直试图解决以下错误:
超时已过期。从池中获取连接之前经过的超时时间。这可能是因为所有池连接都在使用中并且达到了最大池大小。
据我所知,我们所有的DbContext
请求都包含using
,但它看起来似乎没有被处理或其他东西。
有没有办法确定网络应用是否泄漏连接?我可以试试其他的东西吗?!
我试图增加SQL Server中的超时时间,将池大小从默认值100增加到200作为临时结果,但它没有帮助,这不是我想要的解决方案。
任何建议都会有所帮助。
答案 0 :(得分:0)
I think I have a case similar to yours. Our old project version (still using EF4) leaks connections when my code does NOT touch the context. The context is created, a new connection allocated, but on Dispose() the context does not seem to return its connection.
If I just perform one little query (.First() on any random table) on that underutilized context, the situation improves.
A more recent branch of my project uses EF6. That code works fine.
What helped me track this down was SQL Profiler. I also knew roughly what my problem user was doing, so I repeated his steps and kept an eye on Profiler's SPID column. Then I stepped through parts of the code until I got one of the ghost connections I was chasing.
(I stumbled across this just now, so I have not had time to investigate further)