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

Invariant fails in destructor of MigrationChunkClonerSourceLegacy on shutdown

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.15, 3.6.5, 3.7.6
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v3.6, v3.4
    • Sharding 2018-05-07
    • 1

      When we try to cleanup the MigrationSourceManager on error (cleanupOnError), we also clean up the MigrationChunkClonerSourceLegacy object (call cancelClone, which calls _cleanup), and then the MigrationChunkClonerSourceLegacy object is destructed. In the destructor, there's an invariant

      invariant(!_deleteNotifyExec);
      

      _deleteNotifyExec is a unique_ptr to a PlanExecutor object. In theory, in _cleanup(), it should be reset and destructed - hence the invariant. However, if an exception is thrown in _cleanup before this happens, and then ~MigrationChunkClonerSourceLegacy gets called, the program will abort since we're throwing an exception while already throwing an exception, which is A Bad Thing™. In the case of BF-8673 this seems to be what happened, presumably due to one of the functions in _cleanup failing due to shutdown being in progress. We could potentially fix this by wrapping these functions in a try-catch, or instead of using _deleteNotifyExec.reset() we could just std::move(_deleteNotifyExec) into the local scope so that _deleteNotifyExec will indeed be empty no matter what, and this invariant won't fail.

            Assignee:
            matthew.saltz@mongodb.com Matthew Saltz (Inactive)
            Reporter:
            matthew.saltz@mongodb.com Matthew Saltz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: