-
Type: Bug
-
Resolution: Works as Designed
-
Priority: 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.
- is duplicated by
-
SERVER-57622 $indexStats only reports primary shard index information
- Closed
- is related to
-
SERVER-45032 Allow $planCacheStats to target every shardsvr node in a sharded cluster
- Closed
- related to
-
SERVER-34633 Allow $currentOp to retrieve operations from all members of each shard in a cluster
- Closed