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

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

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

      _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@mongodb.com Benety Goh
            Reporter:
            benety.goh@mongodb.com Benety Goh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: