-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Avoid redundant looping in property metadata #29805
Conversation
@@ -858,29 +858,37 @@ private void Create(IEntityType entityType, CSharpRuntimeAnnotationCodeGenerator | |||
var principalProperty = property; | |||
for (var i = 0; i < 10000; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 10,000 really the appropriate number here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be the length of the longest FK chain allowable in the model
Can you say a bit more about what is happening here? What are the situations where the 10,000 limit will be hit? Also, which tests cover these cases? |
The code is traversing FKs. The 10000 limit will be hit if there's an FK cycle in the model. These models are invalid and will fail validation, but the current code runs before validation, so it shouldn't fail before validation runs. Tests:
efcore/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs Line 578 in f732875
|
The customer report didn't fail in validation. I get this was likely a bug, but it makes me nervous that we still have a very high limit such that some other bug could cause very slow model building without failing in validation. Should we not just fail early when we exhaust the loop, rather than assuming model validation will fail? |
Sure, but only in main |
Only in main seems reasonable. |
3f93fcc
to
f5bc9b0
Compare
f5bc9b0
to
bc1fdcc
Compare
Fixes #29642