[SERVER-18062] Creating an index on a collection in a non-existent database when connected to mongos throws error Created: 15/Apr/15  Updated: 05/Feb/16  Resolved: 19/Jun/15

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 3.1.2
Fix Version/s: 3.1.5

Type: Bug Priority: Major - P3
Reporter: Emily Stolfo Assignee: Kaloian Manassiev
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-19036 mongos returns error code 60 (databas... Closed
Related
related to SERVER-17723 Sharding catalog cache Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

1) Connect to mongos.
2) Create an index on a collection in a database that doesn't exist.

Sprint: Sharding 5 06/26/16
Participants:

 Description   

When connected to a mongos, creating an index on a collection in a non-existent database throws an error.

Here is the output from mongosniff using the ruby driver:

127.0.0.1:63099  -->> 127.0.0.1:61017 ruby-driver.$cmd  168 bytes  id:14	20
	query: { createIndexes: "grid.chunks", indexes: [ { key: { files_id: 1, n: 1 }, unique: true, name: "files_id_1_n_1" } ] }  ntoreturn: -1 ntoskip: 0
127.0.0.1:61017  <<--  127.0.0.1:63099   106 bytes  id:89ba	35258 - 20
	reply n:1 cursorId: 0
	{ code: 60, ok: 0.0, errmsg: "database ruby-driver not found" }

I've confirmed that an error is not thrown when connected to a single mongod:

127.0.0.1:63603  -->> 127.0.0.1:27017 ruby-driver.$cmd  142 bytes  id:2	2
	query: { createIndexes: "test", indexes: [ { key: { name: 1 }, unique: true, name: "name_1" } ] }  ntoreturn: -1 ntoskip: 0
127.0.0.1:27017  <<--  127.0.0.1:63603   129 bytes  id:1	1 - 2
	reply n:1 cursorId: 0
	{ createdCollectionAutomatically: true, numIndexesBefore: 1, numIndexesAfter: 2, ok: 1.0 }



 Comments   
Comment by Githook User [ 19/Jun/15 ]

Author:

{u'username': u'kaloianm', u'name': u'Kaloian Manassiev', u'email': u'kaloian.manassiev@mongodb.com'}

Message: SERVER-18062 Implicitly create database for createIndexes

Also moves some commands out of commands_public.cpp in an effort to get
rid of this file.
Branch: master
https://github.com/mongodb/mongo/commit/79a9091df8f56bed80c9a53c1cf943e76dc4c8d8

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