-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Somehow a mismatch in the ShapedCommandContext entries resulting in KeyNotFoundException #7863
Comments
I'd think this is quite a problem. We don't know if we release an alteration of this code (that doesn't crash EF) that it will not show up in production under load in any other way. Basically somewhere the underlying model is broken in a way that is quite scary. Please at least give some response, any at all is better than this complete silence. Mind you the reproduction of this issue is 100% within a few tries so this is not some sort of heisenbug you should just ignore /cc @ajcvickers |
@NinoFloris We triage issues multiple times per week. This issue was filed after our first triage this week and our second one for this week is today. We will assign someone to investigate at that time. However, from looking at the info above, I suspect we are going to need more information to be able to reproduce it. A simplified complete project or code listing would be ideal. If that's not possible, then at least some information about what your model looks like and what queries are being executed. |
It took us a while to pinpoint the exact cause but this is the smallest we can get :) https://gist.github.com/NinoFloris/2c91585c047050e00e388e94edc09a98
|
So how does this problem actually manifest? I definitely know it is an expression visiting problem but where I would have to look then is unknown terrain for me. I presume there is an expression visitor that decides that the nested function should be visited. Is there a visitor that decides query shape equality? E.g. same where's, from, joins, projection and other expression bits but fails to take into account the argument names when they are not db parameters? So as I've asked in my first post already:
I do really like to know the answer to: My educated guess is that is where it fails to take into account a nuance around nested functions that cannot be translated to sql with respect to their arguments not being db parameters, therefore failing to distinguish they are different queries. |
…sulting in KeyNotFoundException - Found an edge case where we can extract different parameters during parameterization but end up with a single query in query cache.
This check does not do a ContainsKey before trying to access the key in the other cache entry:
https://github.com/aspnet/EntityFramework/blob/f386095005e46ea3aa4d677e4439cdac113dbfb1/src/EFCore.Relational/Query/Internal/ShaperCommandContext.cs#L44
Steps to reproduce
It requires a few tries to reproduce as it's non deterministic due to the cache entries needing to get in there in the right order.
I don't know how the
ShapedCommandContext
works, when a new one is constructed or how only this one has mismatching arguments but I hope you can shed some light on thisFurther technical details
EF Core version: dev
Database Provider: Npgsql
Operating system: OSX
IDE: VSCode dotnet cli 1.0 tooling
The text was updated successfully, but these errors were encountered: