-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(NODE-5628): bulkWriteResult.insertedIds does not filter out _ids that are not actually inserted #3867
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AC on the ticket has a requirement of perf tests covering the changes. We do have perf tests covering these 2 scenarios so I don't think we need to add anything but at least a run to report what the impact is of this change would be helpful. (The script is npm run check:bench
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still missing the requested test structure changes and updated wording.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple quick test changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The section of your PR body between "RELEASE_HIGHLIGHT_START" and "RELEASE_HIGHLIGHT_END" is what ends up being put in the release notes for this change.
I have a few suggestions:
-
current title:
BulkWriteResult.insertedIds
Bug Fix- Let's make is a bit more descriptive as a first touch point to what is changing here. "Inserted ids in bulk write results filtered for successful insertion" (or something like that, I don't think my phrasing is ideal here 🤔)
-
current body: When invalid id(s) is/are attempted to be inserted through a
BulkWrite
orInsertMany
, they will no longer appearBulkWriteResult.insertedIds
.- It's not only invalid id(s) right? I believe there are other possible write errors that can indicate an id was not actually inserted. If so, let's generalize the language.
- When referencing APIs it helps to match up the monospace with what users expect to see in their usages, so instead of
InsertMany
we should refer to.insertMany()
orcollection.insertMany()
(same for.bulkWrite()
).- So, in the same area of concern,
BulkWriteResult.insertedIds
should reference precisely how users would access theinsertedIds
prop in the scenario we are changing. This probably calls for a code block where you showtry/catch
insertMany
inside thecatch
you access the insertedIds however they are meant to be accessed:error.result.x.y.z.insertedIds
- So, in the same area of concern,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code changes lgtm, just looking for the release highlights updates now, TIA
Description for NODE-5628
Before this change,
BulkWriteResult.insertedIds
(1) would return an Object containing all attempted insertedIds, regardless of if any of the inserts failed. This affectsBulkWrite
andInsertMany
operations. After this PR is merged,BulkWriteResult.insertedIds
will reflect which _ids were actually inserted.Other Notes for Reviewers
InsertMany
operation; however, I was able to reproduce it generally for any insert operation that returnsBulkWriteResult
namelyBulkWrite
.BulkResult.insertedIds
will still contain unsuccessful inserted_ids
. TheBulkResult
class is not user facing.BulkResult.writeErrors
list property, rather than the actual direct insert response from the server, since the batch result does not contain_id
information.Is there new documentation needed for these changes?
Yes, it needs to be communicated to users that when an insert does not succeed through a
bulkwrite()
orcollection.insertMany()
, it will no longer appear in the error's.result.insertedIds
What is the motivation for this change?
See release highlights.
Release Highlight
Inserted ids in bulk write only contain successful insertions
Prior to this fix the bulk write error's
insertedIds
field contained ids of all attempted inserts in a bulk operation.When a
bulkwrite()
or aninsertMany()
operation rejects one or more inserts, throwing an error, the error'sBulkWriteResult
property will be filtered to only contain successfully inserted ids (ex:error.result.insertedIds
).Bug Description
Previous Behavior
The error's
.result.insertedIds
does includes all attempted inserts, regardless of if they failed or not.New Behavior
The error's
.result.insertedIds
does not include unsuccessful inserts.Namely,
Checklist
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript