Hello,
I’m currently trying to use find().maxTimeMS() to help prevent against long running find queries that can happen during periods of heavy server load. I’m not quite sure I understand how it works exactly.
For example, I was trying to test out maxTimeMS using a development environment (using a value of 1 just to see if it would do anything) but it seems like a query can still take a while and not get terminated.
[debug] o.m.d.p.command - Sending command '{"find": "<collection>", "filter": {<query>}, "sort": {<sort>}, "limit": 6, "maxTimeMS": 1}' with request id 1579 to database userdb on connection [connectionId{localValue:60}] to server <ip>:27017
[debug] o.m.d.p.command - Execution of command with request id 1579 completed successfully in 37.44 ms on connection [connectionId{localValue:60}] to server <ip>:27017
So even though this command is being limited to 1ms, it still completes in 37.44ms (again I’m just trying to test this in order understand it). Something similar happens if I use Robo 3T to execute the find query.
What am I missing? Does the maxTimeMS not limit the request like this? Should I use something else to safeguard against long-running queries?
Thanks in advance.