GH-163: Stage only the difference from a Record's last synchronized state on save - #164
Open
jtnelson wants to merge 1 commit into
Open
GH-163: Stage only the difference from a Record's last synchronized state on save#164jtnelson wants to merge 1 commit into
jtnelson wants to merge 1 commit into
Conversation
…tate on save A save previously wrote a Record's entire remembered state, so an instance with a stale view erased changes that other writers committed after it was loaded. Every Record now keeps a per-field baseline of the state it last loaded or persisted, and a save stages only the difference: per-element adds and removes for collection fields and realm membership, and a write or clear for a scalar field only when its value changed. A field the instance never touched stages nothing, so concurrent changes to it survive. hasUnsavedChanges() now reports whether a save would write anything, so a mutation with no serialized effect (e.g., reordering a List) is no longer an unsaved change. The baseline replaces the whole-record checksum and the realm modification flag as the single change-tracking mechanism. Saver gained add and no longer has reconcile.
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.
Summary
A save previously wrote a
Record's entire remembered state, so an instance with a stale view erased changes that other writers committed after the instance was loaded (the seat and vault data loss in cinchapi/cinchapi-server#151 and cinchapi/cinchapi-server#145). A save now writes only the difference between the record's current state and the state it last loaded or saved.Fixes #163.
Behavior
hasUnsavedChanges()reports whether a save would write anything. A mutation with no serialized effect (for example, reordering aList, since the database stores an unordered set of values) is not an unsaved change.Savergainedaddand no longer hasreconcile.beforeSavegating, save and delete listeners,preventStaleWrites, and the single-key atomic operations keep their existing contracts.Scope
GH163; its reproduction tests fail against the prior save semantics..versionbump is deferred to release.