diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2021-12-07 11:08:45 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-12-07 11:33:42 +0000 |
commit | afaf05e8ee1ffee77f33154799e4270449249cf4 (patch) | |
tree | 1ab158daa0e24dcab213c574cbece2903ba0d322 /src/mongo/db/s/migration_source_manager.h | |
parent | af27a14d78730524f4eaf2e22f3fcf625ddcdc27 (diff) | |
download | mongo-afaf05e8ee1ffee77f33154799e4270449249cf4.tar.gz |
SERVER-61759 Do not expose the cloner directly from the MigrationSourceManager
Diffstat (limited to 'src/mongo/db/s/migration_source_manager.h')
-rw-r--r-- | src/mongo/db/s/migration_source_manager.h | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/src/mongo/db/s/migration_source_manager.h b/src/mongo/db/s/migration_source_manager.h index 7b1b9b825fa..bc7462fb875 100644 --- a/src/mongo/db/s/migration_source_manager.h +++ b/src/mongo/db/s/migration_source_manager.h @@ -80,6 +80,15 @@ public: CollectionShardingRuntime::CSRLock& csrLock); /** + * If the currently installed migration has reached the cloning stage (i.e., after startClone), + * returns the cloner currently in use. + * + * Must be called with a both a collection lock and the CSRLock. + */ + static std::shared_ptr<MigrationChunkClonerSource> getCurrentCloner( + CollectionShardingRuntime* csr, CollectionShardingRuntime::CSRLock& csrLock); + + /** * Instantiates a new migration source manager with the specified migration parameters. Must be * called with the distributed lock acquired in advance (not asserted). * @@ -156,17 +165,6 @@ public: void abortDueToConflictingIndexOperation(OperationContext* opCtx); /** - * Returns the cloner which is being used for this migration. This value is available only if - * the migration source manager is currently in the clone phase (i.e. the previous call to - * startClone has succeeded). - * - * Must be called with a both a collection lock and the CSRLock. - */ - std::shared_ptr<MigrationChunkClonerSource> getCloner() const { - return _cloneDriver; - } - - /** * Returns a report on the active migration. * * Must be called with some form of lock on the collection namespace. @@ -246,6 +244,20 @@ private: // The current state. Used only for diagnostics and validation. State _state{kCreated}; + // Responsible for registering and unregistering the MigrationSourceManager from the collection + // sharding runtime for the collection + class ScopedRegisterer { + public: + ScopedRegisterer(MigrationSourceManager* msm, + CollectionShardingRuntime* csr, + const CollectionShardingRuntime::CSRLock& csrLock); + ~ScopedRegisterer(); + + private: + MigrationSourceManager* const _msm; + }; + boost::optional<ScopedRegisterer> _scopedRegisterer; + // The epoch of the collection being migrated and its UUID, as of the time the migration // started. Values are boost::optional only up until the constructor runs, because UUID doesn't // have a default constructor. @@ -255,16 +267,16 @@ private: // The version of the chunk at the time the migration started. boost::optional<ChunkVersion> _chunkVersion; - // Contains logic for ensuring the donor's and recipient's config.rangeDeletions entries are - // correctly updated based on whether the migration committed or aborted. - boost::optional<migrationutil::MigrationCoordinator> _coordinator; - // The chunk cloner source. Only available if there is an active migration going on. To set and // remove it, a collection lock and the CSRLock need to be acquired first in order to block all // logOp calls and then the mutex. To access it, only the mutex is necessary. Available after // cloning stage has completed. std::shared_ptr<MigrationChunkClonerSource> _cloneDriver; + // Contains logic for ensuring the donor's and recipient's config.rangeDeletions entries are + // correctly updated based on whether the migration committed or aborted. + boost::optional<migrationutil::MigrationCoordinator> _coordinator; + // Holds the in-memory critical section for the collection. Only set when migration has reached // the critical section phase. boost::optional<CollectionCriticalSection> _critSec; |