2

I have 3 config server and two shards. Each shard has a primary, secondary and an arbiter.

This is running with the following mongod settings:

storageEngine=wiredTiger

wiredTigerJournalCompressor=zlib

wiredTigerCollectionBlockCompressor=zlib

The mongos instance created the following log entries below about not being able to get a lock during the sharding balancing. All the data can be queried fine however.

Also all seems fine with sh.status() command:

shards:

{  "_id" : "ib3_prod_rs0",  "host" : "ib3_prod_rs0/ip-10-0-13-119.ec2.internal:27017,ip-10-0-21-50:27017" }

{  "_id" : "ib3_prod_rs1",  "host" : "ib3_prod_rs1/ip-10-0-6-138:27017,ip-10-0-8-202.ec2.internal:27017" }

balancer:

Currently enabled:  yes

Currently running:  yes

    Balancer lock taken at Wed Apr 01 2015 00:00:49 GMT+0000 (UTC) by 54.163.248.60:27017:1427843620:1804289383:Balancer:1681692777

Failed balancer rounds in last 5 attempts:  0

Migration Results for the last 24 hours: 

    No recent migrations

How can I debug what is going on?

2015-03-31T23:41:06.542+0000 I SHARDING [Balancer] moveChunk result: { ok: 0.0, errmsg: "could not acquire collection lock for cubes_prod.pushqueues to migrate chunk [{ : MinKey },{ : MaxKey }) :: caused by :: could not get status from ser...", $gleStats: { lastOpTime: Timestamp 0|0, electionId: ObjectId('551b29f564e83f84e725241e') } } 2015-03-31T23:41:06.543+0000 I SHARDING [Balancer] balancer move failed: { ok: 0.0, errmsg: "could not acquire collection lock for cubes_prod.pushqueues to migrate chunk [{ : MinKey },{ : MaxKey }) :: caused by :: could not get status from ser...", $gleStats: { lastOpTime: Timestamp 0|0, electionId: ObjectId('551b29f564e83f84e725241e') } } from: ib3_prod_rs1 to: ib3_prod_rs0 chunk: min: { UserKey: MinKey } max: { UserKey: 0 }

  • What is ser... , was the server name and you change it? – Antonios Apr 1 '15 at 0:03
  • It seems truncated so I'm not sure I start mongos with: mongos --configdb ip-10-0-19-83.ec2.internal,ip-10-0-12-96.ec2.internal,ip-10-0-7-243.ec2.internal --keyFile /etc/mongodb-keyfile --logpath /var/log/mongos/mongos.log. Could this be caused by a permissions problem like the keyfile ? – klall Apr 1 '15 at 0:06
  • What is interesting is that I get this error message ONLY for those collections that are empty (db.pushqueues.count() is 0). I suppose the data from collections with data are not moving to other shards since the balancer hasn't decided to yet. Previously with Mongo 2.6.7, I could see chunks migrating to different shards easily. I suppose I should see that when we have more data as the algorithms might be different in Mongo 3.0 with the Wired Tiger engine. Just a guess. – klall Apr 1 '15 at 3:07
2

According to what you found out yourself, I think I can provide a detailed explanation.

How chunk migration works (simplified)

Here is how chunk migration works (simplified for the sake of shortness):

  1. When chunk exceeds the configured chunkSize (64MB by default), the mongos which caused the size increase will split the chunk.
  2. That chunk is split on the shard the original chunk resided on. Since the config servers do not form a replica set, it has to update all three config servers.
  3. If the difference in the number of chunks reaches the chunk migration threshold, the cluster balancer will initiate the migration process.
  4. The balancer will try to acquire a balancing lock. Note that because of this there can be only one chunk migration at any given point in time. (This will become important in the explanation what happened.)
  5. In order to acquire the balancing lock, the balancer needs to update the config on all three config servers.
  6. If the balancing lock is acquired, the data will be copied over to the shard with the least chunks.
  7. After the data is successfully copied to the destination, the balancer updates the key range to shard mapping on all three config servers
  8. As a last step, the balancer notifies the source shard to delete the migrated chunk.

What happened in your case

Your data was increasing to a point where chunks had to be split. At this point, all three of your config servers were available and the metadata was updated accordingly. Chunks splitting is a relatively cheap operation in comparison to chunk migration and may happen often, so under load, you usually have a lot more chunk splits than migrations. As said before, only one chunk migration can happen at any given point in time.

Due to whatever problems, one or more of your config servers became unreachable after the chunks were split, but before enough chunks were migrated to balance them out below the chunk migration threshold, since there can only be one running chunk migration at any given point in time. Bottom line: Some time before every chunk that needed to be migrated was actually migrated, one or more of your config servers became unavailable.

Now the balancer wanted to migrate a chunk, but could not reach all config servers to acquire the global migration lock. Hence the error message.

How to deal with such situation

It is very likely that your config server were out of sync. In order to deal with this situation, please read Adam Comerfords answer to mongodb config servers not in sync. Follow it to the letter.

How to prevent

Plain and simple: use MMS. It is free, gives a lot of information about health and performance and using the automation agent, administration of a MongoDB cluster can be done a lot faster.

I tend to suggest to install at least 3 monitoring agents, so you can have a scheduled downtime on one while maintaining redundancy with the others.

MMS has alerting capabilities, so you will be notified if one of your config servers becomes unavailable, which is a serious situation.

  • Thank you for the detailed answer, I would upvote but just joined dba.stackexchange.com. – klall Apr 9 '15 at 20:31
  • @klall: Don't worry, not doing this for rep. As long as it helps, I am happy. – Markus W Mahlberg Apr 9 '15 at 20:39
0

This problem turned out to be a networking issue.

We operate all our mongo environment in a VPC. It seems like the config servers had connectivity issues when doing balancing. When I allowed all traffic inbound/outbound, I got a different error from mongos: "data transfer error".

I was still stuck until I wiped out the entire data for all the config servers and started again with all traffic inbound/outbound allowed.

What still perplexes me is what ports are used for shard balancing. I was able to add the shards no problem through mongos without errors so I assumed that was sufficient.

If anyone can provide a better answer that would be great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.