Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-69945

Synchronize setting/canceling ASIO timers

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.2.0-rc0
    • Affects Version/s: None
    • Component/s: Internal Code
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Service Arch 2022-10-17, Service Arch 2022-10-31, Service Arch 2022-11-14
    • 5

      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.

            Assignee:
            amirsaman.memaripour@mongodb.com Amirsaman Memaripour
            Reporter:
            amirsaman.memaripour@mongodb.com Amirsaman Memaripour
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: