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

TMDS and TMRS should use CancelableExecutors instead of explicitly checking for token cancellation

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • Server Serverless 2021-11-29

    Description

      Both the TenantMigrationDonorService and TenantMigrationRecipientService do explicit checking for whether a local cancellation token has been aborted at the beginning of many (most?) stages of their run methods (example, example). These services can be changed to use a CancelableExecutor instead, which will do this check automatically before deciding to run a continuation.

      this:

      CancellationToken token;
      return ExecutorFuture(**executor)
        .then([] {
          uassert(ErrorCodes::CallbackCanceled, "Donor service interrupted", !token.isCanceled());
          ...
        })
        .onError( ... )
        .onCompletion( ... )
      

      becomes:

      CancellationToken token;
      return ExecutorFuture(**executor)
        .then([] {
          ...
        })
        .thenRunOn(CancelableExecutor::make(executor, token))
        .onError( ... )
        .onCompletion( ... )
      

      (you can also just return ExecutorFuture(CancelableExecutor::make(executor, token)))

      Note to whoever takes this ticket on, there might be nuanced reasons that a service might not want to cease execution if the abort token has been cancelled. For instance, the TMDS currently assumes the first stage (_enterDataSyncState) always completes a write of the initial state document to the database even if the token was cancelled. This can be overcome by moving the insertion to the error handler, or ensuring that the continuation is run on the raw executor (.thenRunOn(executor))

      Attachments

        Activity

          People

            didier.nadeau@mongodb.com Didier Nadeau
            matt.broadstone@mongodb.com Matt Broadstone
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: