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

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.4.5, 3.5.7
    • Component/s: Sharding
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v3.4
    • Steps To Reproduce:
      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});
    • Sprint:
      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

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: