-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem using transactions on sql server #573
Comments
Hello @KorpEduardoSikora , It seems to be a block/deadlock problem caused by the transaction. Increasing the timeout could solve the problem, but that solution is bad since it will lead to even more issues in this case. One possible solution would be to lock the table during the Delete operation. For example: ctx.Items.Delete(x => x.UseTableLock = true); btw, a good idea to allow a predicate directly in the Best Regards, Jon Performance Libraries Runtime Evaluation |
Hello @JonathanMagnan I tried the solution you suggested, and for almost a week it seemed to solved the problem. I'm open for more suggestions, and if I find anything on my side I'll let you know.. Thanks!! |
Do your company have tools that can show you some blocking or deadlock issue on your SQL Server? Our SQL might be the cause, but another one could be the cause as well which we need to better understand what's happening in your database when this issue occurs. |
Hey @JonathanMagnan , Turns out that the problem was with Microsoft.Data.SqlClient. They introduced a bug with their new package and was fixed in 1.1.1. See dotnet/SqlClient#262. After I upgraded to 1.1.1 all problems gone away. Thank you |
Description
I'm experiencing an issue with my Unit Of Work transactions and batch operations.
The error is occurring in the following scenario:
The code
The code above works perfectly... and it is called multiple times a minute, and could be invoked in parallel by multiple customers...
The problem
So... the "perfectly" is not always perfect...
The problem I'm facing and that I've been trying to fix for days happens when:
Somehow the first operation gets stuck on line 4, so the transaction is completed and the dispose method of the "Using" is never invoked and the transactions does not get rolled back. The Sql never throws a time out exception for the first request, only the following ones.
PS: The transaction is "lazy-applied", this means it is only applied when the DBContext is used / when a query to the database is invoked.
Exception
Here is the stack trace from the thrown exception:
Fiddle or Project
In the following days I'll try to create a simple app that reproduces this scenario.
The real problem is, this is only happening in a production environment. I could not reproduce this using two machines invoking 1000 requests each when debugging it.
Further technical details
Any ideas on what might be happening?? I'll give more details if needed!!
Thanks in advance.
The text was updated successfully, but these errors were encountered: