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

make TaskExecutor::cancel return whether the task was successfully canceled

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.0-rc0
    • Component/s: Networking
    • None
    • Fully Compatible
    • Platforms 2016-10-31

      In at least one case (SERVER-26524), we had to add a brittle workaround because canceling a task does not guarantee that CallbackCanceled is delivered to the callback (if the task completes before cancel() is called, the actual response will be delivered instead).

      I see how it's difficult to directly return whether CallbackCanceled will be delivered since the task is canceled by post()'ing to the asio::io_service::strand:

      https://github.com/mongodb/mongo/blob/r3.4.0-rc0/src/mongo/executor/thread_pool_task_executor.cpp#L360 ->
      https://github.com/mongodb/mongo/blob/r3.4.0-rc0/src/mongo/executor/network_interface_asio.cpp#L427 ->
      https://github.com/mongodb/mongo/blob/r3.4.0-rc0/src/mongo/executor/network_interface_asio_operation.cpp#L114-L122

      but perhaps a blocking version of TaskExecutor::cancel (or a flag that indicates whether it should block) could be added?

            Assignee:
            mira.carey@mongodb.com Mira Carey
            Reporter:
            esha.maharishi@mongodb.com Esha Maharishi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: