-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Improved timestamps option handling in bulkWrite #14546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vkarpov15
merged 2 commits into
Automattic:master
from
sderrow:bulk-write-timestamps-fix
Apr 29, 2024
Merged
Improved timestamps option handling in bulkWrite #14546
vkarpov15
merged 2 commits into
Automattic:master
from
sderrow:bulk-write-timestamps-fix
Apr 29, 2024
Conversation
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
vkarpov15
approved these changes
Apr 29, 2024
|
Honestly, I think this PR is the way to go. Allowing setting |
This was referenced May 21, 2024
This was referenced May 21, 2024
Merged
This was referenced May 21, 2024
This was referenced Jun 7, 2024
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 #14536
Summary
There's a fairly inconsistent experience with the
timestampsoption inbulkWriteright now:insertOneoperations is by specifyingtimestampsin the the top-levelbulkWriteoptionsupdateOneandupdateManyhave theirtimestampsoption set purely at the operation leveltimestampsoption forreplaceOneoperationsLet's debate desired behavior here, but this PR introduces a hierarchy in order to (mostly) prevent breaking changes:
timestampsis specified within a given operation (e.g.,op.updateOne.timestamps), then use ittimestampssetting in the top-levelbulkWriteoptions and use it if it existstruePros
insertOneis fully controlled by a different level thanupdateOneandupdateMany. But it's not 100% non-breaking (see below)bulkWritecommands. I've run into this scenario myself, so I understand the benefitCons
bulkWritewith a mix ofinsertOneandupdateOnecommands, you currently controlinsertOneat the top level andupdateOneat the operation level. Suppose you want to set timestamps for allupdateOnecommands but NOT for anyinsertOnecommands. You would do that today by NOT specifying anything fortimestampsin theupdateOnecommands and specifyingtimestamps: falsein the top-level options. Moving forward, with this PR as written, the samebulkWritewill no longer set timestamps on anything.Alternatives
insertOne.timestampsandreplaceOne.timestampsoptions. But we need to leave the top-leveltimestampsoption in order to not breakinsertOnetimestamp control for existing users. This will remain an inconsistent experience, as top-level will only controlinsertOnecommandstimestampsaltogether and just doingtimestampsspecification at the command level for all command types. Since it's a breaking change, delay landing this until 9.Xtimestampsoption forbulkWritehas never been officially documented, so we can remove it without it being a breaking change. AddinsertOne.timestampsandreplaceOne.timestampsoptions, and ship with 8.X. Honestly this is probably the optimal outcome from a simplicity/consistency/speed perspective...Conclusion
After writing out everything above, I'm thinking my current solution as written is the worst of both worlds! Out of the alternatives listed above, I'm partial to alternative 3, but I don't know how others think about the argument that removing top-level
timestampsis non-breaking.