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

[resharding] Create a CancelableOperationContext type to bridge CancelationToken and OperationContext interrupt

    • Fully Compatible
    • Sharding 2021-03-22
    • 2

      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.

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            blake.oler@mongodb.com Blake Oler
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: