[SERVER-29066] Sharded findAndModify will not implicitly create the database if it does not exist Created: 04/May/17  Updated: 30/Oct/23  Resolved: 05/May/17

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 3.4.5, 3.5.7

Type: Bug Priority: Major - P3
Reporter: Misha Tyulenev Assignee: Kaloian Manassiev
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.4
Steps To Reproduce:

Start a ShardingTest and run:

t = db.find_and_modify4;
t.drop();
 
// this is the best way to build auto-increment
function getNextVal(counterName) {
    var ret = t.findAndModify({
        query: {_id: counterName},
        update: {$inc: {val: 1}},
        upsert: true, 'new': true,
    });
    return ret;
}
 
assert.eq(getNextVal("a"), {_id: "a", val: 1});

Sprint: Sharding 2017-05-29
Participants:

 Description   

The sharded findAndModify will fail with NamespaceNotFound error if the database does not exist. The problem was introduced by this change.



 Comments   
Comment by Githook User [ 14/Jun/17 ]

Author:

{u'username': u'kaloianm', u'name': u'Kaloian Manassiev', u'email': u'kaloian.manassiev@mongodb.com'}

Message: SERVER-29066 Reenable disabled findandmodify1.js in the mixed shard version suite
Branch: master
https://github.com/mongodb/mongo/commit/9ef02c273f84b6a3819b3245a8e9f04efa6fcdef

Comment by Githook User [ 06/May/17 ]

Author:

{u'username': u'kaloianm', u'name': u'Kaloian Manassiev', u'email': u'kaloian.manassiev@mongodb.com'}

Message: SERVER-29066 Implicitly create the database in findAndModify
Branch: v3.4
https://github.com/mongodb/mongo/commit/381995f9dcee3c538a3658da00bf49f40bf3af5d

Comment by Githook User [ 05/May/17 ]

Author:

{u'username': u'kaloianm', u'name': u'Kaloian Manassiev', u'email': u'kaloian.manassiev@mongodb.com'}

Message: SERVER-29066 Implicitly create the database in findAndModify
Branch: master
https://github.com/mongodb/mongo/commit/fa52a0600d80b939775d233d911ea9998636cf96

Generated at Thu Feb 08 04:19:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.