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});
Sharding 2017-05-29
Description
The sharded findAndModify will fail with NamespaceNotFound error if the database does not exist. The problem was introduced by this change.