We are facing issue inproduction. maxSessions

We are encountering maxSessions peaking out in mongo db due to which the application in not able to create more connection.

As of now we have 3 node cluster Primary secondry secondry.

We see all read and write operations happening on Primary node and none of the traffic is going to secondry.

Tried shifting read traffic to secondry nodes but that results in stale dataset.

Help would be highly appreciated.

Hi @abhishek_sharma3

This sounds like an issue for either our technical services (support team) or our professional services (consulting team) rather than a question related to this MongoDB University course.

In the case of maximum utilisation of any resource, you can either scale up the hardware to support the higher utilisation or you can limit the number of requests being made.

If this is an Atlas deployment, I’d suggest moving to a higher tier to support the workload. If this is running on your own hardware, I’d suggest contacting sales as it looks like there are several factors here that require deeper discussion.

Kindest regards,

1 Like

Hi Eoin,

Can you give me a link of correct support channel.
What is the quickest way to connect with support. We are running community edition on our own amazon kubernetess cluster.

Warm regards,

Wellcome to the MongoDB Community Forums @abhishek_sharma3!

Since you originally posted this issue in a MongoDB University category, it was definitely off-topic (not related to the course) so I moved it to the more general category of Ops and Admin for visibility.

Since your issue sounds likely to require more dedicated investigation, Eoin was suggesting Commercial Support or Consulting Services might be more appropriate for resolution of your production issue. You can contact MongoDB Sales to discuss options or find a local consultant if you have a preference.

If you want to try to solve your issue with public advice in the community forums, you can also continue discussion in the forums but will need to provide more details and be prepared for some back and forth as we try to work out what your issue may be.

It would be helpful to know:

  • specific version of MongoDB server
  • O/S version
  • output of db.serverStatus().connections on your current primary
  • specific error message indicating the application is not able to create more connections
  • how many .wt files are in your MongoDB dbPath

The most likely starting place for connection limits is checking your ulimit configuration on UNIX-like operating systems, but we need more details about your deployment to provide relevant suggestions.


Hi Stennie,

Thank you so much for prompt response. Here are the details.

root@mongodb-1:/# cat /etc/os-release
VERSION="16.04.6 LTS (Xenial Xerus)"
PRETTY_NAME="Ubuntu 16.04.6 LTS"

  1. MongoDB VERSION
root@mongodb-1:/# mongo
MongoDB shell version v4.0.12
connecting to: mongodb:/Localhost/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("4755946b-0f96-43b2-ab24-74a8dfddd828") }
MongoDB server version: 4.0.12
Server has startup warnings:
2021-07-30T01:18:37.549+0000 I STORAGE  [initandlisten]
2021-07-30T01:18:37.549+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2021-07-30T01:18:37.549+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2021-07-30T01:18:40.448+0000 I CONTROL  [initandlisten]
2021-07-30T01:18:40.448+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2021-07-30T01:18:40.448+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2021-07-30T01:18:40.448+0000 I CONTROL  [initandlisten]
  1. Connections
psc:PRIMARY> db.serverStatus().connections
        "current" : 1172,
        "available" : 837688,
        "totalCreated" : 819557,
        "active" : 5
  1. Error msg

com.mongodb.MongoQueryException: Query failed with error code 261 and error message ‘cannot add session into the cache’ on server mongodb-1.mongodb.shared.svc.cluster.local:27017 at com.mongodb.operation.FindOperation

  1. .wt files count and size

Count - 711
Size - 4.9G


Hi @abhishek_sharma3 Is the issue resolved. If it is please could you share the resolution here. I’m currently facing this issue.