Repository navigation
Fold mutations of one MongoDB record into one write - #166
Merged
Merged
Conversation
Write one op per program that changes the record, in order, in the chain's transaction, so validators and unique indexes see each document as they would one program at a time. Unfold a chain too large for one command, report NOT_APPLIED rather than NOT_STARTED in a replay, give every folded put a result when no session starts, and split a write only when more than one remains after folding.
A program whose caller left before the batch reports NOT_STARTED and joins no chain, and a chain without a live caller ends at once, so it never reaches MongoDB. The docs say MongoDB writes each changed document in one ordered bulkWrite.
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.
MongoDB now folds queued mutations of one record the way Search does since #165, so a client that keeps rewriting the same records stops queueing behind itself. Puts and deletes of a record collapse to the last of them, and Lua programs of a record run in order on the transaction's single read with one write per record; creates, replaces and backend expressions still run one at a time.
Each mutation keeps its own result: a program whose caller leaves before the write is left out and the chain is evaluated again, programs rejected on a document only a failed commit would have made real fail with it, and only a rejected document replays the chain one mutation at a time.