[SERVER-21823] Update / findAndModify with {upsert: true} should report nMatched:0 nModified:0 if results in an insert Created: 09/Dec/15 Updated: 22/Mar/16 Resolved: 29/Jan/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Diagnostics, Write Ops |
| Affects Version/s: | 2.6.11, 3.0.7, 3.2.0 |
| Fix Version/s: | 3.3.2 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | David Storch | Assignee: | Tess Avitabile (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Operating System: | ALL |
| Sprint: | Query F (02/01/16) |
| Participants: |
| Description |
|
Consider an update operation with the {upsert: true} flag whose query predicate does not match any of the documents in the collection:
This update operation does not match any documents, nor does it modify any existing documents, but in nonetheless generates the following log line:
Instead of nMatched:1 and nModified:1 this should report nMatched:0 and nModified:0. This applies to both update and findAndModify for both the log and the profile collection. |
| Comments |
| Comment by Githook User [ 29/Jan/16 ] |
|
Author: {u'username': u'tessavitabile', u'name': u'Tess Avitabile', u'email': u'tess.avitabile@mongodb.com'}Message: should report nMatched:0 nModified:0 if results in an insert |
| Comment by David Storch [ 09/Dec/15 ] |
|
This is not a regression. I believe the problem in some form affects at least 2.6, 3.0, and 3.2. In fact, I purposefully preserved this behavior at one point during 3.0 development since I was working on a pure refactor for explain: It looks like UpdateResult is actually correct, but this is only because there is some crazy accounting that the write commands do: I have not checked on the findAndModify command response or the GLE response. |
| Comment by J Rassi [ 09/Dec/15 ] |
|
Dave, I have a couple of follow-up questions:
|