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

Prevent race condition in Migration Destination Manager from swallowing an exception

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.15, 3.6.5, 3.7.6, 4.0.0-rc0
    • Affects Version/s: 3.4.14, 3.6.4, 3.7.3
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v3.6, v3.4
    • Sharding 2018-04-23
    • 54

      A triggerable race condition exists in the Migration Destination Manager's use of the producer-consumer queue. Upon throwing from inside the insert batch function, both of these will happen:

      1. The inserter thread will kill the operation with the insert batch function's exception.
      2. The guard on the inserter thread will close the consumer end of the queue.

      If the main thread is currently fetching another batch from remote, it will try to push the batch to the queue before checking for an operation context interrupt. The queue will throw back its own exception, `ProducerConsumerQueueEndClosed`. The queue's exception will be the exception returned to the client. This results in the wrong error code returned.

      This can be fixed by adding another checkForInterrupt in between the fetch batch function and the push to the queue, in case this race condition is triggered.

            Assignee:
            blake.oler@mongodb.com Blake Oler
            Reporter:
            blake.oler@mongodb.com Blake Oler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: