Session resource leak

Hi - Im running a single mongod in a docker container and every couple of weeks Im no longer available to connect to the server using python/mongo or compass all with the error:

com.mongodb.MongoQueryException: Query failed with error code 261 and error message ‘Unable to add session into the cache because the number of active sessions is too high’ on server *******:27017

Available sessions looks good:

    rs0:PRIMARY> db.serverStatus().connections
    {
    	"current" : 77,
    	"available" : 52351,
    	"totalCreated" : 335185,
    	"active" : 1
    }

we are running :
MongoDB shell version v4.0.10
MongoDB server version: 4.2.8

How can I investigate this issue? Thanks
Duncan

Hi @Duncan_Kerr and welcome onboard :slight_smile:!

Have a look to this ticket, it looks very similar.
Are you running pymongo 3.10?

Maybe you could consider upgrading to MDB 4.4.0 and pymongo 3.11.0?

Also, does your server has enough RAM? Do you close the connections & cursors your create correctly?

we just upgraded which was when this started. Our drivers are quite old, but we operate a large mongo estate so we have various contraints on what can be changed.

Hi @Duncan_Kerr

This issue is related to the fact that you have reached a 1000000 allowed default open sessions and for some reason they are not getting purged (maxSessions parameter).

There is probably a session leak as a result of a bug or incompatibility of the driver and the server.

Please upgrade to latest compatible drivers and see if after a bounce of the cluster the issue persists.

https://docs.mongodb.com/drivers/ - See needed compatible drivers.

Best regards,
Pavel

2 Likes

Hi, @Duncan_Kerr Is the issue resolved. Could you share the details here.

Regards,
Rohith