Description
mgo
has a single single timeout for read/write operations causes issues when setting sensible limits:
-
Setting an (excessive) write limit of 10 seconds means all queries must return in 10 seconds or the
read()
times out - effectively makingTimeout
a query execution timeout. -
A timeout of 1 minute (time for the queries to complete) means calling
write()
on an unresponsive socket blocks the caller for 1 minute while the socket times out.
There's some interesting interplay between timeouts too:
-
The DialInfo.Timeout is not used when dialing connections, but a custom dialer can be passed to bound the dial time.
-
The
mongoSocket.timeout
, set indirectly byDialInfo.Timeout
- used as a network operation timeout (read/write). -
The
session.syncTimeout
which bounds the amount of time spent synching the cluster state when acquiring a new session, defaults to 60s. -
The
session.sockTimeout
which is used assocket.timeout
for connections spawned by calling a operation when the pool is empty, defaults to 60s. -
The
mongoCluster.syncServer()
which is hard coded to 5 seconds (syncSocketTimeout
incluster.go
) and used to dial a connection if the pool is empty, creating a socket in the pool with asocket.timeout
of 5 seconds. -
The hard coded timeout of 10 seconds when performing a
isMaster()
cluster call, results in socket in the pool withsocket.timeout
of 10 seconds.
This doesn't include the pool connection wait timeout (session.poolTimeout
) or the iter/changestream timeouts, etc.
This ticket is to track fixing the two hard-coded timeouts, and splitting Timeout
into ReadTimeout
and WriteTimeout
in a backwards compatible way.