Lab - Shard a Collection // Script validate_lab_shard_collection fails allway

Hello Community,
i need help and i did not have more ideas:

since hours i couldn´t get any results fors this scipt. for testeing i have set the shard_key to (sku,name,regualarPrice and salePrice) with re-import from the dataset before activateing the new settings:

i get in all tests allways fallowing error:
“No documents found in m103.products - make sure you import the dataset into the
‘products’ collection in the ‘m103’ database.”

my actual Test Status fom shard-cluster is:
vagrant@m103:~$ mongo admin --host “” -u m103-admin -p m103-pass --authenticationDatabase admin
MongoDB shell version v3.6.9
connecting to: mongodb://
Implicit session: session { “id” : UUID(“f704a2b0-2614-48c2-96f2-0c41238ba98e”) }
MongoDB server version: 3.6.9
MongoDB Enterprise mongos> use m103
switched to db m103
MongoDB Enterprise mongos> db.products.count()
MongoDB Enterprise mongos> sh.status()
— Sharding Status —
sharding version: {
“_id” : 1,
“minCompatibleVersion” : 5,
“currentVersion” : 6,
“clusterId” : ObjectId(“5c4ebf9bc2628deec0f39090”)
{ “_id” : “m103-repl”, “host” : “m103-repl/,,”, “state” : 1 }
{ “_id” : “m103-repl-2”, “host” : “m103-repl-2/,,”, “state” : 1 }
active mongoses:
“3.6.9” : 1
Currently enabled: yes
Currently enabled: yes
Currently running: no
Failed balancer rounds in last 5 attempts: 4
Last reported error: Could not find host matching read preference { mode: “primary” } for set m103-repl
Time of Reported error: Mon Jan 28 2019 12:33:09 GMT+0000 (UTC)
Migration Results for the last 24 hours:
4 : Success
{ “_id” : “applicationData”, “primary” : “m103-repl”, “partitioned” : false }
{ “_id” : “config”, “primary” : “config”, “partitioned” : true }
shard key: { “_id” : 1 }
unique: false
balancing: true
m103-repl 1
{ “_id” : { “$minKey” : 1 } } -->> { “_id” : { “$maxKey” : 1 } } on : m103-repl Timestamp(1, 0)
{ “_id” : “m103”, “primary” : “m103-repl”, “partitioned” : true }
shard key: { “sku” : 1 }
unique: false
balancing: true
m103-repl 2
m103-repl-2 1
{ “sku” : { “$minKey” : 1 } } -->> { “sku” : 23153496 } on : m103-repl-2 Timestamp(2, 0)
{ “sku” : 23153496 } -->> { “sku” : 28928914 } on : m103-repl Timestamp(2, 1)
{ “sku” : 28928914 } -->> { “sku” : { “$maxKey” : 1 } } on : m103-repl Timestamp(1, 2)
{ “_id” : “testDatabase”, “primary” : “m103-repl”, “partitioned” : false }

I have testet the complete recration form the sharded cluster, i have upgrade the vagrant setting with additinal 2 vCPU and 8192 GB Ram.
I have read and try the soulutions in the related topics:

How long could it take to get a positive result. I have importeed the dataset with following command:

"mongoimport --drop /dataset/products.json --port 26000 -u "m103-admin" -p "m103-pass" --authenticationDatabase "admin" --db m103 --collection products"

If i check the inserted dokuments i get the following count:
MongoDB Enterprise mongos> use m103
switched to db m103
MongoDB Enterprise mongos> db.products.count()

A can login to evry mongodb instance and the mongo service as well.

If anyone have an addintional idea´s how to get ths f… script working.
The script runs now longer than 1Hour with the same result…

Thats totally frustrating…

1 Like

wow after over one hour in a loop i get the corret answer…

Please mongodb univerity team, please take care one this “error” in future courses. This is more than frustrating und wasted time…

Hi @Wolfgang_62450,

Sorry for the frustration this caused. This is not the expected behavior so we need to debug it.

Can you send me the logs of your shard cluster?
We need to understand what was causing the cluster (or validation scripts) to hang.


1 Like

What I suspect is that with an under power (cpu, ram and disks) setup, it takes that much time for the shared cluster to have all the data at the right place. We should not forget that we are talking about 9 mongod instances and a mongos all fight for the same resources.

I am running on a i7 cpu, 32Gb ram with a NVMe Plextor for the OS and Samsung SSD 850 PRO for the data. I got the correct results withing a few minutes.

I just had the same issue - glad I saw this discussion! After about 20 minutes, the count corrected from 734669 to 516784 and I was finally able to get the validation code.