2 / 2
Apr 10

Hi, there.

I have mongodb-org-server version 8.0.6 and friends installed in a Ubuntu Noble Docker container. I am very new to MongoDB. I am trying to get the killAllSessions() function from either pymongo or mongosh to work. So far, my attempts have not been successful even though the killAllSessions() return assures me that it has worked.

Here’s what I have tried in this StackOverflow Question.

Would anyone tell me if there is anything special that is required to kill any sessions that are reported from the $listLocalSessions aggregration call? I’m stumped.

Thanks.

Rodney Lott

After much experimentation and such, I think I’ve solved my comprehension problem. Essentially, I’ve been bringing a PostgreSQL (PG) mentality to this situation and that has prevented me from seeing the bigger picture here.

Here’s what I’ve learned:

  • The kill* operators in MongoDB do indeed kill sessions, operations, etc. correctly. I confirmed this mostly with my killOp() experiments.
  • In PG, you can kill “client sessions” off (i.e. drop their network connections to the DB). It is a necessary step when dropping SQL DB’s for example. MongoDB client connections (e.g. mongosh, a pymongo session) are not tied exclusively to a particular database and so MongoDB has no reason to require killing client connections for dropping a DB.
  • MongoDB clients like mongosh and pymongo have logic inside them to keep things alive and so killing sessions and operations might not make a visual difference on the client side.

This topic will close 5 days after the last reply.