[SERVER-73895] Sharding not enabled on MongoDB Created: 13/Dec/22  Updated: 27/Feb/23  Resolved: 27/Feb/23

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

Type: Bug Priority: Major - P3
Reporter: Muhammad Shawaiz Ghazanfar Assignee: Yuan Fang
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Kubernetes Cluster using bitnami helm,mongo 6.0.1


Assigned Teams:
Server Triage
Participants:

 Description   

Problem Statement/Rationale

recently the sh.enableSharding() is working on a database which i have created but by applying sh.ShardCollection() it displays "MongoServerError: sharding not enabled for db".

Steps to Reproduce

Create any db ,then apply sh.enableSharding() and after that  create collection and apply sh.shardcollection() with the help of shard key.

Expected Results

Shard Key would be enable on my shardcollection.

Actual Results

"MongoServerError: sharding not enabled for db".

Additional Notes

 



 Comments   
Comment by Yuan Fang [ 27/Feb/23 ]

Hi mohammad.shawaiz97@gmail.com,

We haven’t heard back from you for some time, so I’m going to close this ticket. If this is still an issue for you, please provide additional information and we will reopen the ticket.

Regards,
Yuan

Comment by Yuan Fang [ 13/Feb/23 ]

Hi mohammad.shawaiz97@gmail.com,

We still need additional information to diagnose the problem. If this is still an issue for you, would you please upload the complete log? I've created a secure upload portal for you. Files uploaded to this portal are hosted on Box, are visible only to MongoDB employees, and are routinely deleted after some time.

For the cluster spanning a time period that includes the incident, would you please archive (tar or zip) and upload to that link:

  • The complete mongod logs
  • The mongos log (mongos.log)
  • The config server log (configsvr.log)

If you have any questions, feel free to ask. Thank you!

Regards,
Yuan

Comment by Maurizio Casimirri [ 29/Jan/23 ]

Hi mohammad.shawaiz97@gmail.com, thank you so much for sharing additional info. This doesn't seem to be a mongosh issue, but rather something more inherent to some other part of the stack in your specific setup. We will re-assign this ticket to a team that would be able to assist you in the best way.

In order to confirm that and to ensure a smooth and efficient resolution process, it would be fantastic if you could provide us with the complete log file in addition to the information you've already shared. Feel free to redact details you want to hide replacing them with a "<redacted>" placeholder.

Having all the relevant information readily available from the log file can save us from the need for multiple back-and-forth interactions, and allow us to address and fix the issue as quickly as possible. Thanks for your help!

Comment by Muhammad Shawaiz Ghazanfar [ 13/Dec/22 ]

We are using bitnami mongodb sharded "https://github.com/bitnami/charts/tree/main/bitnami/mongodb-sharded/#installing-the-chart".Two months ago, We had restored data from standalone architecture to sharded architecture, enabled sharded, applied sharded key on collection created. It was working perfectly fine. If we still create new collection and apply on it ,then it works smoothly. 1 replica of 1 shard went to a CrashLoopBack for sometime due to storage issue but it was resolved immediately. 

 

Now, when we create a new db , enable Sharding on it " sh.enableSharding("my_db")" then it responds 

{
  ok: 1,
  '$clusterTime':

{     clusterTime: Timestamp(

{ t: 1678966557, i: 1 }

),
    signature:

{       hash: Binary(Buffer.from("b5da1b9a2539ecdaf77096012e36a014b51c492b", "hex"), 0),       keyId: Long("7925145979144201565")     }

  },
  operationTime: Timestamp({ t: 1678966557, i: 1 })
}

 

But when i create a new collection and apply "sh.shardCollection("my_db.my_collection", {"_id": "hashed"})", then the error message it shows is "MongoServerError: sharding not enabled for db my_db".

 

The LOG given below seems to be different in the logs.

 

{"t":\{"$date":"2022-12-13T14:50:46.263+00:00"}

,"s":"I", "c":"CONTROL", "id":20710, "ctx":"LogicalSessionCacheRefresh","msg":"Failed to refresh session cache, will try again at the next refresh interval","attr":{"error":"NoProgressMade: no progress was made executing batch write op in config.system.sessions after 5 rounds (514 ops completed in 7 rounds total)"}}

 

The kubernetes setup, we are using is also working perfectly fine as other dbs are also deployed on it and are in working state.

Comment by Anna Henningsen [ 13/Dec/22 ]

mohammad.shawaiz97@gmail.com Are you able to provide a log file as suggested above?

Can you provide full steps to reproduce? This does not appear to happen with the regular MongoDB 6.0.1 binaries. Have you verified that this is not an issue with the specific kubernetes setup you’re using?

Comment by Muhammad Shawaiz Ghazanfar [ 13/Dec/22 ]

Databases which has been created two months ago, any new collection applied on it is working. This issue is being faced on new creating databases.

Comment by Muhammad Shawaiz Ghazanfar [ 13/Dec/22 ]

[direct: mongos] my_db> sh.enableSharding("my_db")
{
  ok: 1,
  '$clusterTime':

{     clusterTime: Timestamp(\{ t: 1678966557, i: 1 }

),
    signature:

{       hash: Binary(Buffer.from("b5da1b9a2539ecdaf77096012e36a014b51c492b", "hex"), 0),       keyId: Long("7925145979144201565")     }

  },
  operationTime: Timestamp({ t: 1678966557, i: 1 })
}
[direct: mongos] my_db> sh.shardCollection("my_db.my_collection", {"_id": "hashed"})
MongoServerError: sharding not enabled for db my_db

 

Comment by Muhammad Shawaiz Ghazanfar [ 13/Dec/22 ]

[direct: mongos] my_db> sh.enableSharding("my_db")
{
  ok: 1,
  '$clusterTime':

{     clusterTime: Timestamp(\{ t: 1678966557, i: 1 }

),
    signature:

{       hash: Binary(Buffer.from("b5da1b9a2539ecdaf77096012e36a014b51c492b", "hex"), 0),       keyId: Long("7925145979144201565")     }

  },
  operationTime: Timestamp({ t: 1678966557, i: 1 })
}
[direct: mongos] my_db> sh.shardCollection("my_db.my_collection", {"_id": "hashed"})
MongoServerError: sharding not enabled for db my_db

 

Comment by Le Roux Bodenstein [ 13/Dec/22 ]

Hi Muhammad

Could you upload a log file?

Comment by Muhammad Shawaiz Ghazanfar [ 13/Dec/22 ]

It seems like the function "sh.enableCollections()" or "sh.enable Sharding " have some sort of bug in it.

Generated at Thu Feb 08 06:25:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.