Fix rollback edge case - #530
Merged
Merged
Conversation
JonoPrest
commented
May 16, 2025
Comment on lines
-162
to
-163
| ->Belt.Array.map(row => { | ||
| self.insertFn(sql, row, ~shouldCopyCurrentEntity) |
Collaborator
Author
There was a problem hiding this comment.
The bug creeps in because all entities in a rollback batch are treated as if they are part of the diff with the shouldCopyCurrentEntity flag.
This only makes a difference if
- The entity update was a new one (not in the diff but maybe a new event emitted after the reorg)
- Within the reorg threshold of the current reorg, a second reorg takes place, rolling back to the same block or before
- The entity then appears in the diff as if it should be deleted (so to the framework looks like it doesn't exist in the db)
- The handler has some conditional logic on the previous state of the entity (the conditional logic won't work as expected) OR the handler does not make any updates to the entity after the reorg in which case the entity would be unexpectedly deleted
JonoPrest
commented
May 16, 2025
|
|
||
| fn aggregated_selection(cfg: &system_config::SystemConfig) -> Self { | ||
| let mut transaction_fields: HashSet<_> = cfg | ||
| let mut transaction_fields: BTreeSet<_> = cfg |
Collaborator
Author
There was a problem hiding this comment.
This had non deterministic ordering, just changed to a BTreeSet to keep ordering consistent.
JonoPrest
commented
May 16, 2025
Comment on lines
+167
to
+168
| // For new entities, apply "containsRollbackDiffChange" from param | ||
| containsRollbackDiffChange, |
Collaborator
Author
There was a problem hiding this comment.
We now keep track in the in memory store if the entity update contains changes from a rollback diff
JonoPrest
commented
May 16, 2025
| | Set(entity) => Set(entity) | ||
| | Delete => Delete({id: entityId}) | ||
| }, | ||
| containsRollbackDiffChange, |
Collaborator
Author
There was a problem hiding this comment.
The history row gets the "containsRollbackDiffChange" flag
JonoPrest
force-pushed
the
jp/fix-reorg-bug
branch
from
May 16, 2025 09:45
24bf289 to
988ad4d
Compare
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.
No description provided.