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

Error message in collection creation failure contains incorrect namespace

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial - P5
    • Resolution: Fixed
    • Affects Version/s: 2.6.0-rc2
    • Fix Version/s: 2.6.1, 2.7.0
    • Component/s: Write Ops
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Completed:
    • Steps To Reproduce:
      Hide

      With a patched server, run this JS:

      var myDB = db.getSiblingDB('repro');
      myDB.dropDatabase();
       
      var bulk = myDB.system.indexes.initializeUnorderedBulkOp();
      bulk.insert({ns: 'repro.' + new Array(120).join('a'), key: {foo: 1}, name: 'bar'});
      bulk.execute();

      Show
      With a patched server, run this JS: var myDB = db.getSiblingDB('repro'); myDB.dropDatabase();   var bulk = myDB.system.indexes.initializeUnorderedBulkOp(); bulk.insert({ns: 'repro.' + new Array(120).join('a'), key: {foo: 1}, name: 'bar'}); bulk.execute();

      Description

      Issue Status as of April 15, 2014

      ISSUE SUMMARY
      A write command error message contains an incorrect collection name when a collection creation fails.

      USER IMPACT
      Error diagnosis confusion. Users relying on the write error return strings can parse the wrong collection name.

      WORKAROUNDS
      None.

      RESOLUTION
      Corrected the collection name in the error message.

      AFFECTED VERSIONS
      Version 2.6.0 is affected by this bug.

      PATCHES
      The patch is included in the 2.6.1 production release.

      Original description

      On line 939, the 'could not create collection' message appends request->getNS(). It should append request->getTargetingNS() instead, given the preceding createCollection call.

      I don't see an obvious way to trigger the bug, so I just manually patched batch_executor.cpp to verify that the wrong namespace is being used in the message.

      src/mongo/db/commands/write_commands/batch_executor.cpp:

      932  _collection = database->getCollection(request->getTargetingNS());
      933  if (!_collection) {
      934      // Implicitly create if it doesn't exist
      935      _collection = database->createCollection(request->getTargetingNS());
      936      if (!_collection) {
      937          result->setError(
      938                  toWriteError(Status(ErrorCodes::InternalError,
      939                                      "could not create collection " + request->getNS())));
      940          return false;
      941    }
      }


      Version: bafd9c7e0e39f86d251271517f518a24acb853c5

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: