CLOSE_WAIT & lsof mongod count increasing

Version : Mongo:v3.6.17
Hi All,

I see thousands of “sock” in lsof and it keeps increasing with no reason in logs.

|mongod|8955|root|19u|sock|0,9|0t0|61158263|protocol:|TCP|
|mongod|8955|root|28u|sock|0,9|0t0|61146906|protocol:|TCP|

lsof -p mongod | grep “0,9” | wc -l
33419

Any configuration suggestion on mongod to reduce?

Hi @Raj_Kumar

Very likely this is a poorly written client application. Opening connections unnecessarily instead of using connection pools.

ss -tn "sport = :27017" or netstat -tn | grep :27017 will give you a list of mongo connections to this host, assuming default port, allowing you to target where the problematic connections are coming from.

poorly written client application

How would I able to trace this out on my client. It is ultimately the mongo carrying the blame. Is there any way to create a dump on mongo to prove that client is misbehaving?

You will want to verify this by identifying where the connections are from to make sure.

3.6.17 Has had a few minor release since, though a quick look did not seem to be related.
3.6.22 released in February is the latest.

What is the client driver and version you are using ?

A poorly written application may, for instance create a new mongo client for every request vs creating one client and reusing it.

this error in mongo oplog when the closewait started increasing

2021-03-18T08:49:20.547+0000 I ASIO [NetworkInterfaceASIO-RS-0] Ending idle connection to host M04:27717 because the pool meets constraints; 2 connections to that host remain open
2021-03-18T08:49:36.601+0000 I ASIO [NetworkInterfaceASIO-RS-0] Ending idle connection to host M03:27717 because the pool meets constraints; 2 connections to that host remain open

org.mongodb.mongo-java-driver_3.7.2.jar
Even 3.6.22 didn’t help!!

Any suggestion is very much appreciated!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.