diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-03-13 15:19:40 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-03-13 18:54:52 -0400 |
commit | 296f242fedb66eff99861f4fa3cda1ffc552ad9d (patch) | |
tree | 53eb40b543826af099429e06c36ef2575122efb6 /src/mongo/db/s/collection_sharding_state.h | |
parent | a1b194059660d78afba0d8750231f48e4f77f2a6 (diff) | |
download | mongo-296f242fedb66eff99861f4fa3cda1ffc552ad9d.tar.gz |
SERVER-29908 Move the migration critical section out of MigrationSourceManager
Diffstat (limited to 'src/mongo/db/s/collection_sharding_state.h')
-rw-r--r-- | src/mongo/db/s/collection_sharding_state.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/mongo/db/s/collection_sharding_state.h b/src/mongo/db/s/collection_sharding_state.h index 14b403cd93f..51ff7d26435 100644 --- a/src/mongo/db/s/collection_sharding_state.h +++ b/src/mongo/db/s/collection_sharding_state.h @@ -35,6 +35,7 @@ #include "mongo/bson/bsonobj.h" #include "mongo/db/namespace_string.h" #include "mongo/db/s/metadata_manager.h" +#include "mongo/db/s/sharding_migration_critical_section.h" namespace mongo { @@ -153,9 +154,16 @@ public: std::vector<ScopedCollectionMetadata> overlappingMetadata(ChunkRange const& range) const; /** - * Returns the active migration source manager, if one is available. + * Methods to control the collection's critical section. Must be called with the collection X + * lock held. */ - MigrationSourceManager* getMigrationSourceManager(); + void enterCriticalSectionCatchUpPhase(OperationContext* opCtx); + void enterCriticalSectionCommitPhase(OperationContext* opCtx); + void exitCriticalSection(OperationContext* opCtx); + + auto getCriticalSectionSignal(ShardingMigrationCriticalSection::Operation op) const { + return _critSec.getSignal(op); + } /** * Attaches a migration source manager to this collection's sharding state. Must be called with @@ -164,6 +172,10 @@ public: */ void setMigrationSourceManager(OperationContext* opCtx, MigrationSourceManager* sourceMgr); + auto getMigrationSourceManager() const { + return _sourceMgr; + } + /** * Removes a migration source manager from this collection's sharding state. Must be called with * collection X lock. May not be called if there isn't a migration source manager installed @@ -255,6 +267,8 @@ private: // Contains all the metadata associated with this collection. std::shared_ptr<MetadataManager> _metadataManager; + ShardingMigrationCriticalSection _critSec; + // If this collection is serving as a source shard for chunk migration, this value will be // non-null. To write this value there needs to be X-lock on the collection in order to // synchronize with other callers, which read it. |