Random errors occur with per-request DbContext

人走茶凉 提交于 2019-12-05 08:31:33

After further investigation I found out that request processing thread sometimes steals DbContext from other thread, so Rashid's implementation of PerRequestLifetimeManager may not be thread safe. I moved to Unity.Mvc3 again and the errors disappeared, I must have made some mistake when I tried that last time.

The only error not related were deadlocks. They were caused by collision of

SELECT ... FROM X JOIN Y ... JOIN Z ...

and

BEGIN TRAN
UPDATE Z ...
UPDATE Y ...
COMMIT TRAN

SELECT locked Y and wanted Z, TRAN locked Z and wanted Y

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!