Mongodb query stuck in cluster

I have a 3 Node MongoDB cluster with Replica Set.

I am executing a find query using an AWS EC2 instance (which has 2 NIC/network interface cards, for reasons undisclosed). My find query has a list with in operator (i.e., db.collection.find({"_id":{"$in":[]}}) and I am using golang mongo driver for this to connect to this database.

In some cases (when the length of the list exceed some number) my MongoDB find query stuck, even though the connection to MongoDB was created. The length of the list is different for different collection and different mongo drivers (I tried the same with pymongo on the same machine), I am able to reproduce the same repeatedly with those specific numbers, even if I changed the data but keep same schema. The same query is working on some other machine. The number is very low, like for one collection that number is 58.

I am not understanding why I am facing this issue, only when I am using a machine with 2 NIC cards and a MongoDB cluster setup.
Any help would be appreciated.
Thank you<3

How much data is being returned for those slow queries?
Do you have an explain output?

Hi @Kobe_W, thank you for your quick reply,
The problem I am facing isn’t exactly how much data is being returned, When the list is over the length of > 58 in case of Go Mongo Drivers, it is not returning any documents, whereas if it is less than 58, it returns me the expected number of data.

The query is executed on _id which is an index for the collection. Even for Python pymongo driver, the number is found to be > 60 and also this was not a problem if I change the machine (one with a single NIC card)
Thank you

Something I noticed is that a find command with 58 IDs (I used ObjectId as the IDs) generates an unencrypted message size of about 1200 bytes. The default packet MTU for most EC2 machines is around 1500 bytes, so any messages >1500b must be split into multiple packets.

If the routing rules for the machine with 2 NICs are somehow misconfigured, it’s possible that the find command is being split into multiple packets and one of the packets is never reaching the database, causing the operation to appear “stuck”. Are you experiencing any other network communication issues between the EC2 machine and MongoDB host(s)?