-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Internal Code
-
None
-
Fully Compatible
-
ALL
-
Service Arch 2022-10-17, Service Arch 2022-10-31, Service Arch 2022-11-14
-
5
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
Mongo's existing RPC system (i.e., NetworkInterface) may use ASIO timers to enforce timeouts. The behavior, however, is racy as threads may set and cancel a timer without synchronization. Consider the following:
- We schedule a remote command through startCommand, but since there are no connections available, the invocation returns before starting any remote command.
- We decide to cancel the scheduled remote command through cancelCommand, which attempts to cancel the timer from here.
- At the same time, the connection pool provides a connection, so NetworkInterface starts sending the remote command and setting the timer as a prerequisite from here.
- Now, we have two threads that are concurrency reading and writing an ASIO-internal value without synchronization:
- The thread canceling the remote command is reading this value.
- The thread that is trying to send the remote command is writing this value.
A possible solution to address this issue is to synchronize setting/canceling timers at NetworkInterface layer.