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

CancelableOperationContext leaks its cancelation future when linked to a long-lived CancellationToken

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.0.0, 7.0.0, 8.1.0-rc0, 8.0.0, 8.2.0-rc0
    • Component/s: None
    • None
    • Server Programmability
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When constructing a CancelableOperationContext, it will create a future in order to kill the associated OperationContext if the cancellation token is canceled. That future is not released in the destructor, but rather, it will stay associated to the cancellation source.

      This is not problematic if the cancellation source is short-lived, for example, linked to a specific operation. However, in some cases, a cancellation source is reused across operations. An example of this is the MigrationDestinationManager: It is a singleton which will create a single cancellation source which is reused across multiple all chunk migrations, and is only canceled on stepdown.

      In the case of the recipient of a chunk migration, this turns into a fast memory leak: The MigrationDestinationManager will create a SessionCatalogMigrationDestination in order to migrate oplog entries associated to sessions. Every iteration of the main loop will create a CancelableOperrationContext, whose cancellation source is linked to the MigrationDestinationManager, and once the migration reaches the ReadyToCommit state, the main loop will spin without throttling, rapidly building memory use.

            Assignee:
            Unassigned Unassigned
            Reporter:
            joan.bruguera-mico@mongodb.com Joan Bruguera Micó
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: