Closed JordanMarr closed 4 years ago
Which database?
Don't use the same context on multiple threads. Instead create a context per thread. (That is a limitation of database driver connection pooling rather than SQLProvider.)
There is a lot of discussion about this in #238
Thanks for the quick reply. It is using SQL Server.
Checking out that discussion now....
I restarted the site after reading your comment, and it is saving now. So that buys me some time. Whew!
Hi! Can I ask you more details please? I'm getting the same issue from one of my users in Production. You closed without any intervention, but did you do anything else at code level then? In my case I don't think it is a concurrency problem.
Hi! Can I ask you more details please? I'm getting the same issue from one of my users in Production. You closed without any intervention, but did you do anything else at code level then? In my case I don't think it is a concurrency problem.
It was not a bug, it was my own hasty configuration error: I had configured it in the asp.net core dependency injection subsystem as a singleton. A total rookie mistake.
Hope that helps!
@JordanMarr Thank you for your prompt reply! I will investigate as per your suggestion.
In my case it was one of the many possible errors from the db (a long user input causing a truncation on a column of a table in MS Sql Server), then my fix, shared here, consisted of (aside from the obvious alter table)
wrapping the updates submit with a try
clearing the updates of the context in case it throws
Honestly (YMMV) I would consider context.ClearUpdates()
as the standard behaviour for exceptions, one should explicitly activate a flag to keep those "wrong" updates active after irrecoverable errors from db, IMO, but this is not the case for the current implementation of SQL Provider, hence my fix in my project.
You might want to get the failed entities for other purposes (e.g. logging as described in my reply), that's why auto-clear is not a good option.
It is a good option, the current behaviour is very prone to errors.
Description
I have a system that has been in production for a few weeks. It has been running fine until this morning where none of the users can save their work.
In the log I see this exception over and over: "System.Exception: Unchanged entity encountered in update list - this should not be possible!"
Any clues as to what this might mean?