[SERVER-13466] Error message in collection creation failure contains incorrect namespace Created: 02/Apr/14  Updated: 11/Jul/16  Resolved: 04/Apr/14

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.6.0-rc2
Fix Version/s: 2.6.1, 2.7.0

Type: Bug Priority: Trivial - P5
Reporter: Kamran K. Assignee: Unassigned
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Steps To Reproduce:

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

Participants:

 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



 Comments   
Comment by Githook User [ 09/Apr/14 ]

Author:

{u'username': u'kkmongo', u'name': u'Kamran Khan', u'email': u'kamran.khan@mongodb.com'}

Message: SERVER-13466 Use correct namespace in write error when collection creation fails

Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
(cherry picked from commit 56136a9d8f165fe9ec74bb4928404206ce63610f)
Branch: v2.6
https://github.com/mongodb/mongo/commit/a9587732dc24b220ad687c06205da9e20906ab45

Comment by Githook User [ 04/Apr/14 ]

Author:

{u'username': u'kkmongo', u'name': u'Kamran Khan', u'email': u'kamran.khan@mongodb.com'}

Message: SERVER-13466 Use correct namespace in write error when collection creation fails

Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
Branch: master
https://github.com/mongodb/mongo/commit/56136a9d8f165fe9ec74bb4928404206ce63610f

Generated at Thu Feb 08 03:31:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.