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

Creating an index on a collection in a non-existent database when connected to mongos throws error

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.5
    • Affects Version/s: 3.1.2
    • Component/s: Index Maintenance
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Hide

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

      Show
      1) Connect to mongos. 2) Create an index on a collection in a database that doesn't exist.
    • Sharding 5 06/26/16

      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 }
      

            Assignee:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Reporter:
            emily.stolfo Emily Stolfo
            Votes:
            0 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved: