Lab Documents in Chunks

Ok, I am a little confused here. I am pretty sure I understand the concept of chunks. After sharding the collection, you use the mongos config database and look in the chunks collection.

If you run db.chunks.find().pretty() you get the following output:

MongoDB Enterprise mongos> db.chunks.find().pretty()

{

“_id” : “config.system.sessions-_id_MinKey”,

“ns” : “config.system.sessions”,

“min” : {

“_id” : { “$minKey” : 1 }

},

“max” : {

“_id” : { “$maxKey” : 1 }

},

“shard” : “m103-repl”,

“lastmod” : Timestamp(1, 0),

“lastmodEpoch” : ObjectId(“5bd93ca65a0d780b33d1fa3d”)

}

{

“_id” : “m103.products-sku_MinKey”,

“lastmod” : Timestamp(2, 0),

“lastmodEpoch” : ObjectId(“5bdbb4545a0d780b33ddf16a”),

“ns” : “m103.products”,

“min” : {

“sku” : { “$minKey” : 1 }

},

“max” : {

“sku” : 23153496

},

“shard” : “m103-repl”

}

{

“_id” : “m103.products-sku_23153496”,

“lastmod” : Timestamp(2, 1),

“lastmodEpoch” : ObjectId(“5bdbb4545a0d780b33ddf16a”),

“ns” : “m103.products”,

“min” : {

“sku” : 23153496

},

“max” : {

“sku” : 28928914

},

“shard” : “m103-repl-2”

}

{

“_id” : “m103.products-sku_28928914”,

“ns” : “m103.products”,

“min” : {

“sku” : 28928914

},

“max” : {

“sku” : { “$maxKey” : 1 }

},

“shard” : “m103-repl-2”,

“lastmod” : Timestamp(1, 2),

“lastmodEpoch” : ObjectId(“5bdbb4545a0d780b33ddf16a”)

}

I am pretty sure that the document searched for in the lab is on the second chunk. Where I am confused is I believe the chunk ID is m103.products-sku_23153496, but when I enter it in the validation it fails. Am I looking at the right area?

Disregard!!! I was looking in the wrong chunk. It is on the first chunk.

what is the chunk id?

Am a bit confused in this question:

hint sh.status() does not provide the chunk ID that you need to report for this lab. Look in the config database for the collection that stores all chunk information. Think in ranges - you want to find the chunk whose range is min <= key < max.

How to identify the required

I have my query returned below output, but how to now identify the chunk_id is where am stucked:

MongoDB Enterprise mongos> db.getSiblingDB(“m103”).products.find({“sku” : 21572585 })
{ “_id” : ObjectId(“573f71c8f29313caab8ba50c”), “sku” : 21572585, “name” : “Star Trek: The Motion Picture/Star Trek II: The Wrath of Kahn (DVD)”, “type” : “Movie”, “regularPrice” :
12.99, “salePrice” : 12.99, “shippingWeight” : “0.25” }
MongoDB Enterprise mongos>

can anyone help or guide to direct me on how to identify the chunk_id in the config database.

Please check db.chunks.find() under config DB

Your chunk id will look like this m103.products-sku_30874349---->example only
each chunk id will have a min and max value
You have to identify which id will have this value-21572585

1 Like

@ Ramachandra_37567

Thanks so much, your reply has helped me to locate and identify the chunk id under which that document exist.

Thanks so much

Is a manual inspection of db.chunks.find() the recommended approach in a production environment? I imagine a lot of chunks being listed by this command and wondering how to narrow the result set.