Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-29066

Sharded findAndModify will not implicitly create the database if it does not exist

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.4.5, 3.5.7
    • Sharding
    • None
    • Fully Compatible
    • ALL
    • v3.4
    • Hide

      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});
      

      Show
      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.

      Attachments

        Activity

          People

            kaloian.manassiev@mongodb.com Kaloian Manassiev
            misha.tyulenev@mongodb.com Misha Tyulenev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: