Skip to content
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

Hidden Exception in LazyLoader.Load(..) Due to exception in InternalEntry.SetIsLoaded(..) #34167

Open
beliakov-mb opened this issue Jul 5, 2024 · 0 comments

Comments

@beliakov-mb
Copy link
Contributor

beliakov-mb commented Jul 5, 2024

An exception thrown inside the try section in LazyLoader.Load(..) can be hidden by an exception thrown from the InternalEntry.SetIsLoaded(..) method.

In my case, I was using EFCore 8.0.6 and received the following exception:

InvalidOperationException: The navigation 'EntityOne.EntityTwo' cannot have 'IsLoaded' set to false because the referenced entity is non-null and is therefore loaded.

Then, I forked and added logging before setting entry.IsLoaded = false and got the original exception:

Microsoft.Data.SqlClient.SqlException (0x80131904): Transaction (Process ID 739) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. Which was not being propagated before the addition.

Unfortunately, reproducing the issue is quite complex and I cannot attach it.

Include provider and version information

EF Core version: 8.0.6
Database provider: MsSqlServer
Target framework: net8
Operating system: ubuntu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants