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:
- The inserter thread will kill the operation with the insert batch function's exception.
- 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.