Failed to change chunk size

Hi every body,

I tried to change chunk size.

Here are what I did :

  1. run command under mongos shell :

MongoDB Enterprise mongos> use config
MongoDB Enterprise mongos> db.settings.save({_id: “chunksize”, value: 2})

  1. import file (outside mongos shell)

mongoimport /dataset/products.part2.json --port 26000 -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin” --db m103 --collection products

  1. run sh.status() inside mongos shell

MongoDB Enterprise mongos> sh.status()

I got response below :

MongoDB Enterprise mongos> sh.status()
— Sharding Status —
sharding version: {
“_id” : 1,
“minCompatibleVersion” : 5,
“currentVersion” : 6,
“clusterId” : ObjectId(“5e0c3ea2b059582faf76252f”)
}
shards:
{ “_id” : “m103-repl”, “host” : “m103-repl/m103:27001,m103:27002,m103:27003”, “state” : 1 }
{ “_id” : “m103-repl-2”, “host” : “m103-repl-2/m103:27004,m103:27005,m103:27006”, “state” : 1 }
active mongoses:
“3.6.16” : 1
autosplit:
Currently enabled: yes
balancer:
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-2
Time of Reported error: Thu Jan 02 2020 00:57:43 GMT+0000 (UTC)
Migration Results for the last 24 hours:
2 : Success
databases:
{ “_id” : “config”, “primary” : “config”, “partitioned” : true }
config.system.sessions
shard key: { “_id” : 1 }
unique: false
balancing: true
chunks:
m103-repl 1
{ “_id” : { “$minKey” : 1 } } -->> { “_id” : { “$maxKey” : 1 } } on : m103-repl Timestamp(1, 0)
{ “_id” : “m103”, “primary” : “m103-repl”, “partitioned” : true }
m103.products
shard key: { “sku” : 1 }
unique: false
balancing: true
chunks:
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)

from the response above I have two concerns :slight_smile:

  1. error

balancer:
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-2
Time of Reported error: Thu Jan 02 2020 00:57:43 GMT+0000 (UTC)
Migration Results for the last 24 hours:
2 : Success

  1. chunk_size is not changed

                      chunks:
                             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) 
    

currently I have no idea why this happens and how to fix this issue.

For any one who ever has experience with similar issue, please advise.

Thank you.

Hi @supriadi_76115,

It’s always useful to mention the chapter and title of the lecture or lab you’re referring to. In your case it’s “Chapter 3: Sharding, Lecture: Chunk”.

Please do the following:

  1. Run the following command on the VM shell and share a screenshot of the output:
    ps -ef | grep [m]ongo
  2. Login to the m103-repl-2 replica set and show us the outputs of:
    a. rs.status()
    b. rs.config()

Hi @supriadi_76115,

You can ignore this error message (given the m103-repl-2 is up and running at the moment).

The most likely reason of getting this error message is that you might have started your mongos process before running the mongod instances for the m103-repl-2.

Couples of things that you need to know here - Even though you have changed the chunk size, no splitting will take place until or unless you perform an insert/update related operation. In addition to this, it takes some time for the entire operation to complete if you have lowered the chunk size.

As, I can see you have imported the data in the same database and collection so it is an insert operation and chunk splitting operation should be triggered.

Please run the sh.status() command again and see if the number of chunks has changed or not. If it hasn’t then please run the following command and share the output :

use m103
db.products.find({}).itcount()

Thanks,
Shubham Ranjan
Curriculum Services Engineer