InitialSyncer::_startupComponent should reset 'component' before returning CallbackCanceled due to shutdown

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 3.4.6, 3.5.7
    • Affects Version/s: 3.4.4, 3.5.6
    • Component/s: Replication
    • None
    • Fully Compatible
    • 15
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      _startupComponent currently resets the unique_ptr if the component's startup() returns an error but not when the parent component is shutting down. This usually doesn't pose a problem except when the sub component is holding some resource that needs to be released if we decide not to proceed with calling its startup().

      https://github.com/mongodb/mongo/blob/fa2dcc33303dd6a2080c108e121da6984d08a9d6/src/mongo/db/repl/initial_syncer.cpp#L1340

      initial_syncer.cpp
      template <typename Component>
      Status InitialSyncer::_startupComponent_inlock(Component& component) {
          if (_isShuttingDown_inlock()) {
              return Status(ErrorCodes::CallbackCanceled,
                            "initial syncer shutdown while trying to call startup() on component");
          }
          auto status = component->startup();
          if (!status.isOK()) {
              component.reset();
          }
          return status;
      }
      

              Assignee:
              Benety Goh
              Reporter:
              Benety Goh
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: