我已经有这个 SemaphoreFullException 安静一段时间了。
总结一下..
我在 IIS 7.5 上使用 ASP.NET v4.0 框架应用程序池(集成)托管了一个应用程序。
我正在使用 Windows 身份验证通过域(isinrole)对我的用户进行身份验证。
我已经看到了有关此主题的所有其他线程,其中建议设置 Pooling = False。
我不想这样做,并且由于性能优势,我想继续使用池化。
我正在使用 Entity Framework 6 来查询数据库,并且我不会在用户代码中的任何位置“处置”dbcontext。
问题似乎出在 DbConnectionPool 代码中。
该错误在任何给定时间随机发生。应用程序是否正在使用并不重要。有时,由于这个问题 - 我必须重新启动 IIS,因为新用户停止进行身份验证。
到目前为止我尝试过的:
- 检查数据库事务对象是否正在被释放。
- 检查 DBContext (ctx) 是否被过早处置。
- 检查应用程序版本(32/62 位)。在本例中 - 我在任何 CPU 模式下构建应用程序,并且我的服务器是 64 位。
注意:在我的应用程序中,我主要使用 linq-to-EF 对象来查询数据库。
Exception: System.Threading.SemaphoreFullException
Message: Adding the specified count to the semaphore would cause it to exceed its maximum count.
StackTrace: at System.Threading.Semaphore.Release(Int32 releaseCount)
at System.Data.ProviderBase.DbConnectionPool.CleanupCallback(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.TimerQueueTimer.CallCallback()
at System.Threading.TimerQueueTimer.Fire()
at System.Threading.TimerQueue.FireNextTimers()
在这方面的任何帮助将不胜感激。