-
Type: Improvement
-
Resolution: Won't Do
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:
-
Server Serverless 2021-11-29
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))