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

report index information on a per-shard basis via getIndexes or similar command

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Indexing, Sharding
    • Labels:
      None

      Description

      In a sharded cluster environment, getIndexes() reports indexes as defined on the database's Primary shard's primary node. It could be useful to have a convenient way of obtaining indexes on a per-shard (or even per-node given getIndexes on a primary reports indexes on that node) basis.

      original

      When creating an index on a shard that does not have the Primary role, mongoS does not find the index.

      For example:

      # Shard information
              {  "_id" : "vinnie""primary" : "shard02""partitioned" : true
                  "version" : {  "uuid" : UUID("2ff1e7eb-0a75-4bde-ac8f-bff4e93dfc4a"),  "lastMod" : 1 } }
      "_id" : "vinnie""primary" : "shard02""partitioned" : true
                  "version" : {  "uuid" : UUID("2ff1e7eb-0a75-4bde-ac8f-bff4e93dfc4a"),  "lastMod" : 1 } }                
      vinnie.companies
                              shard key: { "_id" : 1 }
                              unique: false
                              balancing: true
                              chunks:
                                      shard01 7
                                      shard02 8
                                      shard03 7
      

      Create the index on shard01:

      shard01:PRIMARY> use vinnie;
      switched to db vinnie
      shard01:PRIMARY> db.companies.createIndex({firm: 1}){ "createdCollectionAutomatically" : false, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1,
      

      The result on mongoS:

      mongos> db.companies.getIndexes()mongos> db.companies.getIndexes()
      [ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "vinnie.companies" }]
      

      Now, if I create the index on the Primary shard (shard02), mongoS recognizes:

      mongos> db.companies.getIndexes()mongos> db.companies.getIndexes()
      [ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "vinnie.companies" }, { "v" : 2, "key" : { "firm" : 1 }, "name" : "firm_1", "ns" : "vinnie.companies" }]
      

       
      The proposed solution is to recognize the index independent of the shard role.

        Attachments

          Activity

            People

            Assignee:
            backlog-server-sharding Backlog - Sharding Team
            Reporter:
            vgrippa@gmail.com VINICIUS GRIPPA
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: