[SERVER-43092] collection is sharded in mongos but not enabled in sharding instance Created: 30/Aug/19  Updated: 03/Sep/19  Resolved: 03/Sep/19

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.4.10
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: ren justin Assignee: Danny Hatcher (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Hi all,

I have a 2-shards-3-replicas cluster in prod, config db is 3-replicas and 2 mongos instances, mongo version is 3.4.10.
I already enabled sharding at db level, then try to shard the collection

*mongos> db.user.ensureIndex(\{person_id: "hashed"}, \{background: true})*
{
 "raw" : {
 "prod1/172.31.0.16:27017,172.31.0.76:27017,172.31.0.85:27017" : {
 "createdCollectionAutomatically" : false,
 "numIndexesBefore" : 2,
 "numIndexesAfter" : 3,
 "ok" : 1,
 "$gleStats" : {
 "lastOpTime" : {
 "ts" : Timestamp(1567133797, 47),
 "t" : NumberLong(11)
 },
 "electionId" : ObjectId("7fffffff000000000000000b")
 }
 }
 },
 "ok" : 1
}
*mongos> sh.shardCollection("prod.user", \{ person_id : "hashed" } )*
{ "collectionsharded" : "prod.user", "ok" : 1 }
 
*mongos> db.collections.find(\{_id:"prod.user"})*
{ "_id" : "prod.user", "lastmodEpoch" : ObjectId("5d68a55593c736ce7519fdb8"), "lastmod" : ISODate("1970-02-19T17:02:47.694Z"), "dropped" : false, "key" : \{ "person_id" : "hashed" }, "unique" : false }
 
*mongos> db.user.getShardDistribution()*
 
Shard prod1 at prod1/172.31.0.16:27017,172.31.0.76:27017,172.31.0.85:27017
 data : 12.45GiB docs : 65857922 chunks : 399
 estimated data per chunk : 31.96MiB
 estimated docs per chunk : 165057
 
Totals
 data : 12.45GiB docs : 65857922 chunks : 399
 Shard prod1 contains 100% data, 100% docs in cluster, avg obj size on shard : 203B

Everything seems fine through mongos,but the output in shard instance is below, and the collection still holds on single shard server

*prod1:PRIMARY> db.user.getShardDistribution()*
Collection prod.user is not sharded.

I try to re-shard through mongos, which fails

*mongos> sh.shardCollection("prod.user", \{ person_id : "hashed" } )*
{
 "code" : 20,
 "ok" : 0,
 "errmsg" : "sharding already enabled for collection prod.user"
}

There must be some confusions between mongos and shard, but I'm not sure how to debug, since it's prod, every action should be with caution.
Please help to give some tips, thanks!



 Comments   
Comment by Danny Hatcher (Inactive) [ 03/Sep/19 ]

The message you received when running against the shard itself is misleading. As mentioned in SERVER-42145, the getShardDistribution() command will always report that a namespace is unsharded instead of reporting that the command is only usable against a mongos. You can safely ignore it.

If there are actual issues with your sharding cluster not distributing chunks beyond that one command output, I encourage you to reach out to our community via mongodb-user group or Stack Overflow with the mongodb tag as the SERVER project is for bug reports and feature suggestions.

Generated at Thu Feb 08 05:02:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.