[SERVER-17372] FindAndModify no longer returns "value" if upsert results in an insert and "new" is false Created: 25/Feb/15  Updated: 19/Sep/15  Resolved: 25/Feb/15

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 3.0.0-rc9, 3.0.0-rc10
Fix Version/s: 3.0.0-rc11, 3.1.0

Type: Bug Priority: Blocker - P1
Reporter: Craig Wilson Assignee: David Storch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-17303 concurrent findAndModify ops with ups... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Steps To Reproduce:

To reproduce, run a 3.0.0-rc8 server:

> db.test.remove({})
> db.runCommand({findAndModify: "test", query: {_id: "miss"}, update: {$set: {y:2}}, upsert: true})
{
        "value" : null,
        "lastErrorObject" : {
                "updatedExisting" : false,
                "n" : 1,
                "upserted" : "miss"
        },
        "ok" : 1
}

Here is the result with a 3.0.0-rc9 (and 3.0.0-rc10) server:

> db.test.remove({})
> result = db.runCommand({findAndModify: "test", query: {_id: "miss"}, update: {$set: {y:2}}, upsert: true})
{
        "lastErrorObject" : {
                "updatedExisting" : false,
                "n" : 1,
                "upserted" : "miss"
        },
        "ok" : 1
}

Sprint: Quint 3.1.0
Participants:

 Description   

From 3.0.0-rc8 to 3.0.0-rc9, the server has stopped returning the "value" field from a findAndModify command under certain conditions.

This is causing the .NET driver, for instance, to throw an exception where null used to be returned. Certainly, we could alter the driver to check if the field exists first, but this is a change to the server's API and affects all versions of the .NET driver currently released.



 Comments   
Comment by Githook User [ 25/Feb/15 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-17372 fix findAndModify output when there is an insert in the upsert: true, new: false case

(cherry picked from commit 3c8a4340080524facb1666c632ec1655d53d59cc)
Branch: v3.0
https://github.com/mongodb/mongo/commit/ccb38b6a118809c8df47637d053835555f33d413

Comment by Githook User [ 25/Feb/15 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-17372 fix findAndModify output when there is an insert in the upsert: true, new: false case
Branch: master
https://github.com/mongodb/mongo/commit/3c8a4340080524facb1666c632ec1655d53d59cc

Generated at Thu Feb 08 03:44:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.