Details
Description
If the source shard primary steps down during a migration, it can trigger one of the cleanupOnError scope guards in the MigrationSourceManager. This calls MigrationManager::_cleanup, which can call ShardServerCatalogCacheLoader::waitForCollectionFlush, which will uassert if the node is no longer primary, and because this was called inside a scope guard and isn't caught, the exception triggers std::terminate() and crashes the server.