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

Segfault is possible in MigrationSourceManager when it calls css->getMetadata()->getCollVersion() and the collection was dropped since the migration began.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 3.4.0-rc1
    • None
    • Sharding
    • None
    • Fully Compatible
    • ALL
    • Sharding 2016-10-10

    Description

      The collection can be dropped if the balancer loses the distlock during the migration. Then drop can acquire the distlock and run during the migration.

      This line of code,

      css->getMetadata()->getCollVersion()
      

      can segfault. If the collection is not sharded (say it has been dropped), CollectionShardingState::get creates a CollectionShardingState, which creates an empty MetadataManager with no active metadata. When MetadataManager::getActiveMetadata (via css->getMetadata) is called, it returns an empty ScopedCollectionMetadata object. Then when the ScopedCollectionMetadata object is dereferenced for getCollVersion, a nullptr is accessed.

      This might be solved by additionally checking that css->getMetadata() returns true before proceeding with getCollVersion. css->getMetadata() returns a ScopedCollectionMetadata, which has a bool operator function defined to return true if it actually has a CollectionMetadata.

      Should survey all of css->getMetadata usages to make use they won't segfault.

      Further check in other places in MigrationSourceManager that the collection has not been dropped or recreated (it would have a different epoch in the version).

      Attachments

        Activity

          People

            dianna.hohensee@mongodb.com Dianna Hohensee (Inactive)
            dianna.hohensee@mongodb.com Dianna Hohensee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: