Decide load_related membership against final state#6548
Open
incrypto32 wants to merge 2 commits intomasterfrom
Open
Decide load_related membership against final state#6548incrypto32 wants to merge 2 commits intomasterfrom
incrypto32 wants to merge 2 commits intomasterfrom
Conversation
EntityCache::load_related decided derived field membership against intermediate cache layers, so same-block changes to an entity's parent reference could leave it in the wrong derived collection (or omit it from one it had moved into). Rewrite load_related to build a candidate set from the store baseline plus in-block writes, resolve each candidate's final state by layering store -> updates -> handler_updates the same way get() does, and apply query.matches exactly once against the final state.
…changes Cover six scenarios where an entity's parent reference or presence changes within a block: a single-handler reassignment that should remove the entity from the old parent's derived collection, a cross-handler reassign-then-revert that should leave the intermediate parent's collection unchanged, a cross-handler touch-then-reassign that should add the entity to the new parent's collection, a removal landing in updates and a removal landing in handler_updates that both drop the entity from its collection, and a fresh in-handler creation that should appear in the new parent's collection.
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.
EntityCache::load_relateddecided derived field membership against intermediatecache layers (
self.updatesandself.handler_updatesseparately), so same-blockchanges to an entity's parent reference could leave it in the wrong derived
collection or omit it from one it had moved into.
Rewrite
load_relatedto:key is compatible with the query (entity_type + causality_region).
handler_updates the same way
EntityCache::get()does.query.matchesexactly once against the final state.Closes three previously-distinct failure modes: entities wrongly retained after
moving out of a collection, wrongly retained after a cross-handler revert, and
wrongly omitted after being moved in across handlers.
Scenarios covered by the new tests
self.updatesdrops entity from collectionself.handler_updatesdrops entity from collectionAll six tests are in
store/test-store/tests/graph/entity_cache.rs.