[SERVER-55102] [resharding] Create a CancelableOperationContext type to bridge CancelationToken and OperationContext interrupt Created: 09/Mar/21  Updated: 29/Oct/23  Resolved: 18/Mar/21

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Task Priority: Major - P3
Reporter: Blake Oler Assignee: Max Hirschhorn
Resolution: Fixed Votes: 0
Labels: PM-234-M3, PM-234-T-error-flow
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-55306 Integrate CancelableOperationContext ... Closed
Backwards Compatibility: Fully Compatible
Sprint: Sharding 2021-03-22
Participants:
Story Points: 2

 Description   

In resharding state machines, we would like to rely on one source of truth – the cancelation token, in order to know to stop work. As it stands, many of the systems that resharding calls into are only interruptible by the OperationContext. To solve this problem, we should create the type CancelableOperationContext.

CancelableOperationContext is a class that will contain an OperationContext pointer and a cancelation token. When the token is canceled, if the OperationContext still exists, it will be interrupted.

The aim is to use CancelableOperationContext everywhere in resharding code instead of a regular OperationContext, so that we can easily translate canceling a token to interrupting work.

Some concurrency constraints that must be considered when creating this:

  • We need to prevent the cancellation token from calling killOperation() on a freed OperationContext
  • We need to prevent the OperationContext from being freed while the cancelation token is interacting with it

A mutex on the CancelableOperationContext may be the best way to solve the above.



 Comments   
Comment by Githook User [ 18/Mar/21 ]

Author:

{'name': 'Max Hirschhorn', 'email': 'max.hirschhorn@mongodb.com', 'username': 'visemet'}

Message: SERVER-55102 Create CancelableOperationContext class.
Branch: master
https://github.com/mongodb/mongo/commit/5397acfdb865a7daa605c4f248822d7dbe74bffc

Generated at Thu Feb 08 05:35:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.