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

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance, Sharding
    • None
    • ALL
    • Sharding 2022-03-07, Sharding NYC 2022-03-21, Sharding NYC 2022-05-30, Sharding 2022-06-27

      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.

            Assignee:
            garaudy.etienne@mongodb.com Garaudy Etienne
            Reporter:
            vgrippa@gmail.com Vinicius Grippa
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: