-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 1.11.1
-
Component/s: None
-
None
The mongo connection pool refreshes the ping time by performing an actual ping to the server. With the default configuration in 1.11.x and with a nil op_timeout in later 1.x releases, this operation might block indefinitely. This in itself might not be desired behavior, but unfortunately, the operation is performed while holding a mutex, meaning that any further attempt to calculate the ping time while block by trying to lock the mutex.
The code in question:
https://github.com/mongodb/mongo-ruby-driver/blob/1286982cf2f78c597f24995854cc52f40737ce4c/lib/mongo/connection/pool.rb#L113-L155
A simple workaround for the problem is to ensure op_timeout is non-nil, but that might not be desirable for "normal" operations. Given that the ping operation is essentially optional, it doesn't make any sense that it blocks indefinitely. The ping method supplies a timeout argument to the command call, but on the one hand that timeout seems way to high to be performed while holding the lock, and even so, it doesn't seem to actually be used.