[release/9.0] Take into account store-generated values when ordering update commands#34626
Merged
AndriySvyryd merged 1 commit intorelease/9.0from Sep 9, 2024
Merged
[release/9.0] Take into account store-generated values when ordering update commands#34626AndriySvyryd merged 1 commit intorelease/9.0from
AndriySvyryd merged 1 commit intorelease/9.0from
Conversation
Member
|
@AndriySvyryd - this is for main correct? Given risk assessment (Medium), I would suggest against 9.0 release without proper testing and high confidence. |
Member
Author
It's intended for 9.0 if approved. I do think we have proper testing and I have high confidence it won't cause a regression. It just carries inherent higher risk due to code complexity, similar to most changes in the query pipeline. |
SamMonoRT
approved these changes
Sep 6, 2024
artl93
approved these changes
Sep 6, 2024
cincuranet
approved these changes
Sep 9, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #33023
Description
EF orders update commands in a way that avoids breaking store constraints, like unique indexes.
E.g. if there's a unique index on a
Namecolumn and there's currently a row withJaredand a row withSam. The user wants to update the first row toSamand the second row toArtak. EF needs perform the second update first.This gets complicated when the index is over a column with a store-computed value since EF cannot predict the value it will have after an update. A workaround is to duplicate the store logic in the C# implementation. This client-side value would never be sent to the store but could be used to determine the update order. However, this workaround was broken because we also needed to avoid dependency cycles in the updates that would prevent establishing an order when a row with the same value is deleted and inserted. The way we handled this was by collapsing the delete and insert into an update and ignoring the store-generated values for ordering purposes.
This change to the ordering logic uses more fine-grained approach for determining whether a store-generated value could affect the ordering that works for both scenarios.
Customer impact
For models with a unique index over a computed column the update order can no longer be correctly determined and will throw an exception if it doesn't happen to be correct. The workaround is to send updates to the affected table one-by-one, but this would have a negative perf impact.
How found
Customer reported
Regression
Yes, from 6.0.x
Testing
Tests added.
Risk
Medium. While this code has good test coverage, due to its nature it's hard to predict all the ramifications of this change.