bulkload-with-version-check_v2 #4087
Merged
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.
Currently Marten supports 3 bulk insert modes .
It would be great if Marten also supported an additional mode (or a separate BulkUpdate option) that integrates with IVersion optimistic concurrency.
Desired behavior:
• For each document in the batch:
• insert if it doesn’t exist
• update/overwrite only if IVersion matches the current stored version
• otherwise skip, rather than overwriting or throwing error
This would be very useful for online JSON migrations/backfills without taking the app down.
Example scenario:
• The application performs on-the-fly migrations when a document is loaded/edited after deployment.
• At the same time, a background job migrates all documents in bulk for speed.
• While processing a batch, some documents might already have been migrated/updated by the app due to live traffic.
• In this case, the bulk process should not overwrite those documents — it should skip updates when the stored IVersion has changed since the document was read.
IMPORTANT: I'm not familiar with marten internals . Its my first PR on this project and unfortunately I was not able to make the test pass on my machine even before making any changes to master branch (before the changes from this PR). I could only validate that my new tests are passing and the ones related to bulk loading
UPDATE: this overlaps a bit with #3301