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

Error message in collection creation failure contains incorrect namespace

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Trivial - P5
    • Resolution: Fixed
    • 2.6.0-rc2
    • 2.6.1, 2.7.0
    • Write Ops
    • Fully Compatible
    • ALL
    • 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

              Unassigned Unassigned
              kamran.khan Kamran K.
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: