Comments on: The (In)famous MongoDB Message: Cannot Add Session Into the Cache – TooManyLogicalSessions https://www.percona.com/blog/mongodb-message-cannot-add-session-into-the-cache-toomanylogicalsessions/ Tue, 06 Feb 2024 00:31:56 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: Vinicius Grippa https://www.percona.com/blog/mongodb-message-cannot-add-session-into-the-cache-toomanylogicalsessions/#comment-10973318 Wed, 15 Sep 2021 07:16:19 +0000 https://www.percona.com/blog/?p=76116#comment-10973318 Hi Leo,

Try to use the & in the end of the Mongo command. The way you are running seems to be executing serialized.

/opt/mongodb/4.0.6/bin/mongo localhost:37017/percona –eval “db.data.save({idt: 1})” &

]]>
By: leo https://www.percona.com/blog/mongodb-message-cannot-add-session-into-the-cache-toomanylogicalsessions/#comment-10973316 Tue, 14 Sep 2021 08:13:08 +0000 https://www.percona.com/blog/?p=76116#comment-10973316 #!/bin/bash
for (( c=1; c<=500; c++ ))
do  
   /opt/mongodb/4.0.6/bin/mongo localhost:37017/percona –eval "db.data.save({idt: 1})"
done

i test i on my env,it just open one sessions,not 500.

]]>
By: Vinicius M. Grippa https://www.percona.com/blog/mongodb-message-cannot-add-session-into-the-cache-toomanylogicalsessions/#comment-10973216 Thu, 10 Jun 2021 19:56:06 +0000 https://www.percona.com/blog/?p=76116#comment-10973216 Hi Kay,

Thanks a lot for leaving a comment a here. I’m glad you enjoyed it 🙂

Indeed this issue I forgot to mention. This happens because when you use –shardsrv, mongoD assumes the collection is sharded causing problems since you are using a replica set.

Great findind!

]]>
By: Kay Agahd https://www.percona.com/blog/mongodb-message-cannot-add-session-into-the-cache-toomanylogicalsessions/#comment-10973215 Thu, 10 Jun 2021 19:42:08 +0000 https://www.percona.com/blog/?p=76116#comment-10973215 Thanks Vinicius for these detailed and interesting insights!
I once came across of the same error message but the reason was a misconfiguration of the replica set: the replica set was once part of a cluster (sharded). The cluster has been reduced to only one shard. The remaining shard was finally run as a replica set (no routers and no configservers anymore) BUT the following config entry survived by mistake: “sharding.clusterRole: shardsvr”
The result was that the number of logical sessions constantly increased until it hit the default maximum of 1 million of logical sessions. After removing this parameter from the config and restarting the mongod instance, the number of logical sessions stayed almost constant.
Just in case some of your readers encounter the same problem one day… 🙂

]]>