diff options
author | Randolph Tan <randolph@10gen.com> | 2019-06-18 11:41:13 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2019-06-27 14:08:59 -0400 |
commit | d6834482ef9bbca8fd81e82483dedde965de9574 (patch) | |
tree | f0fb5fd88fbe0bc97054c0282e9f9aa6f802c5ec /src | |
parent | 18a03b671d2a7d71c4af4ae2d115134b90dc9e38 (diff) | |
download | mongo-d6834482ef9bbca8fd81e82483dedde965de9574.tar.gz |
SERVER-40258 Rename CSRLock::lock to CSRLock::lockShared
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/catalog/rename_collection.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/catalog_raii.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/commands/create_indexes.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/index_builds_coordinator.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/active_migrations_registry.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/collection_sharding_state.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/flush_database_cache_updates_command.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/get_database_version_command.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/op_observer_sharding_impl.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/s/shard_filtering_metadata_refresh.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_state_lock.h | 7 |
12 files changed, 20 insertions, 19 deletions
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp index e339e7876c7..b575f1f5d88 100644 --- a/src/mongo/db/catalog/rename_collection.cpp +++ b/src/mongo/db/catalog/rename_collection.cpp @@ -111,7 +111,7 @@ Status checkSourceAndTargetNamespaces(OperationContext* opCtx, { auto& dss = DatabaseShardingState::get(db); - auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss); + auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, &dss); dss.checkDbVersion(opCtx, dssLock); } @@ -429,7 +429,7 @@ Status renameBetweenDBs(OperationContext* opCtx, { auto& dss = DatabaseShardingState::get(sourceDB); - auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss); + auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, &dss); dss.checkDbVersion(opCtx, dssLock); } diff --git a/src/mongo/db/catalog_raii.cpp b/src/mongo/db/catalog_raii.cpp index ea15f87137d..b3f109c90e5 100644 --- a/src/mongo/db/catalog_raii.cpp +++ b/src/mongo/db/catalog_raii.cpp @@ -51,7 +51,7 @@ AutoGetDb::AutoGetDb(OperationContext* opCtx, StringData dbName, LockMode mode, }()) { if (_db) { auto& dss = DatabaseShardingState::get(_db); - auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss); + auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, &dss); dss.checkDbVersion(opCtx, dssLock); } } @@ -184,7 +184,7 @@ AutoGetOrCreateDb::AutoGetOrCreateDb(OperationContext* opCtx, } auto& dss = DatabaseShardingState::get(_db); - auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss); + auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, &dss); dss.checkDbVersion(opCtx, dssLock); } diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index 5a1eeda9117..227c4d843a1 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -361,7 +361,7 @@ Database* getOrCreateDatabase(OperationContext* opCtx, StringData dbName, Lock:: */ void checkDatabaseShardingState(OperationContext* opCtx, Database* db) { auto& dss = DatabaseShardingState::get(db); - auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss); + auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, &dss); dss.checkDbVersion(opCtx, dssLock); } diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index 0b123fe08eb..b25bba1f5fb 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -919,7 +919,7 @@ void IndexBuildsCoordinator::_buildIndex(OperationContext* opCtx, auto db = DatabaseHolder::get(opCtx)->getDb(opCtx, nss.db()); if (db) { auto& dss = DatabaseShardingState::get(db); - auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss); + auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, &dss); dss.checkDbVersion(opCtx, dssLock); } diff --git a/src/mongo/db/s/active_migrations_registry.cpp b/src/mongo/db/s/active_migrations_registry.cpp index f8e26472a8d..55cbfecfa9c 100644 --- a/src/mongo/db/s/active_migrations_registry.cpp +++ b/src/mongo/db/s/active_migrations_registry.cpp @@ -121,7 +121,7 @@ BSONObj ActiveMigrationsRegistry::getActiveMigrationStatusReport(OperationContex // Lock the collection so nothing changes while we're getting the migration report. AutoGetCollection autoColl(opCtx, nss.get(), MODE_IS); auto csr = CollectionShardingRuntime::get(opCtx, nss.get()); - auto csrLock = CollectionShardingRuntime::CSRLock::lock(opCtx, csr); + auto csrLock = CollectionShardingRuntime::CSRLock::lockShared(opCtx, csr); if (auto msm = MigrationSourceManager::get(csr, csrLock)) { return msm->getMigrationStatusReport(); diff --git a/src/mongo/db/s/collection_sharding_state.cpp b/src/mongo/db/s/collection_sharding_state.cpp index 0d8871a0f45..e0dd987600d 100644 --- a/src/mongo/db/s/collection_sharding_state.cpp +++ b/src/mongo/db/s/collection_sharding_state.cpp @@ -218,7 +218,7 @@ void CollectionShardingState::checkShardVersionOrThrow(OperationContext* opCtx) metadata->isSharded() ? metadata->getShardVersion() : ChunkVersion::UNSHARDED(); auto criticalSectionSignal = [&] { - auto csrLock = CSRLock::lock(opCtx, this); + auto csrLock = CSRLock::lockShared(opCtx, this); return _critSec.getSignal(opCtx->lockState()->isWriteLocked() ? ShardingMigrationCriticalSection::kWrite : ShardingMigrationCriticalSection::kRead); diff --git a/src/mongo/db/s/flush_database_cache_updates_command.cpp b/src/mongo/db/s/flush_database_cache_updates_command.cpp index 13429421b43..f1c6009329d 100644 --- a/src/mongo/db/s/flush_database_cache_updates_command.cpp +++ b/src/mongo/db/s/flush_database_cache_updates_command.cpp @@ -129,7 +129,7 @@ public: // propagated back to this shard. This ensures the read your own writes causal // consistency guarantee. auto& dss = DatabaseShardingState::get(autoDb.getDb()); - auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss); + auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, &dss); if (auto criticalSectionSignal = dss.getCriticalSectionSignal( ShardingMigrationCriticalSection::kRead, dssLock)) { diff --git a/src/mongo/db/s/get_database_version_command.cpp b/src/mongo/db/s/get_database_version_command.cpp index 71fc3e4b8ad..899c8c1e33f 100644 --- a/src/mongo/db/s/get_database_version_command.cpp +++ b/src/mongo/db/s/get_database_version_command.cpp @@ -80,7 +80,7 @@ public: AutoGetDb autoDb(opCtx, _targetDb(), MODE_IS); if (auto db = autoDb.getDb()) { auto& dss = DatabaseShardingState::get(db); - auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss); + auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, &dss); if (auto dbVersion = dss.getDbVersion(opCtx, dssLock)) { versionObj = dbVersion->toBSON(); diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp index aa21bce528a..2a751999ca4 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp @@ -76,7 +76,7 @@ public: { auto csr = CollectionShardingRuntime::get(opCtx, *nss); - auto csrLock = CollectionShardingRuntime::CSRLock::lock(opCtx, csr); + auto csrLock = CollectionShardingRuntime::CSRLock::lockShared(opCtx, csr); if (auto msm = MigrationSourceManager::get(csr, csrLock)) { // It is now safe to access the cloner diff --git a/src/mongo/db/s/op_observer_sharding_impl.cpp b/src/mongo/db/s/op_observer_sharding_impl.cpp index 1cc5844cde3..2bd4165b89f 100644 --- a/src/mongo/db/s/op_observer_sharding_impl.cpp +++ b/src/mongo/db/s/op_observer_sharding_impl.cpp @@ -80,7 +80,7 @@ bool OpObserverShardingImpl::isMigrating(OperationContext* opCtx, NamespaceString const& nss, BSONObj const& docToDelete) { auto csr = CollectionShardingRuntime::get(opCtx, nss); - auto csrLock = CollectionShardingRuntime::CSRLock::lock(opCtx, csr); + auto csrLock = CollectionShardingRuntime::CSRLock::lockShared(opCtx, csr); return isMigratingWithCSRLock(csr, csrLock, docToDelete); } @@ -111,7 +111,7 @@ void OpObserverShardingImpl::shardObserveInsertOp(OperationContext* opCtx, return; } - auto csrLock = CollectionShardingRuntime::CSRLock::lock(opCtx, csr); + auto csrLock = CollectionShardingRuntime::CSRLock::lockShared(opCtx, csr); auto msm = MigrationSourceManager::get(csr, csrLock); if (msm) { msm->getCloner()->onInsertOp(opCtx, insertedDoc, opTime); @@ -133,7 +133,7 @@ void OpObserverShardingImpl::shardObserveUpdateOp(OperationContext* opCtx, return; } - auto csrLock = CollectionShardingRuntime::CSRLock::lock(opCtx, csr); + auto csrLock = CollectionShardingRuntime::CSRLock::lockShared(opCtx, csr); auto msm = MigrationSourceManager::get(csr, csrLock); if (msm) { msm->getCloner()->onUpdateOp(opCtx, preImageDoc, postImageDoc, opTime, prePostImageOpTime); @@ -154,7 +154,7 @@ void OpObserverShardingImpl::shardObserveDeleteOp(OperationContext* opCtx, return; } - auto csrLock = CollectionShardingRuntime::CSRLock::lock(opCtx, csr); + auto csrLock = CollectionShardingRuntime::CSRLock::lockShared(opCtx, csr); auto msm = MigrationSourceManager::get(csr, csrLock); if (msm && getIsMigrating(opCtx)) { diff --git a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp index e8de649a76e..78dbafcae2d 100644 --- a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp +++ b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp @@ -249,7 +249,7 @@ void forceDatabaseRefresh(OperationContext* opCtx, const StringData dbName) { } auto& dss = DatabaseShardingState::get(db); - auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss); + auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, &dss); const auto cachedDbVersion = dss.getDbVersion(opCtx, dssLock); if (cachedDbVersion && cachedDbVersion->getUuid() == refreshedDbVersion.getUuid() && diff --git a/src/mongo/db/s/sharding_state_lock.h b/src/mongo/db/s/sharding_state_lock.h index 620cd5f53a0..98db5e58e79 100644 --- a/src/mongo/db/s/sharding_state_lock.h +++ b/src/mongo/db/s/sharding_state_lock.h @@ -47,7 +47,8 @@ public: * Locks the sharding state object with the sharding state object's ResourceMutex in MODE_IS. * When the object goes out of scope, the ResourceMutex will be unlocked. */ - static ShardingStateLock<ShardingState> lock(OperationContext* opCtx, ShardingState* state); + static ShardingStateLock<ShardingState> lockShared(OperationContext* opCtx, + ShardingState* state); /** * Follows the same functionality as the ShardingStateLock lock method, except that @@ -81,8 +82,8 @@ ShardingStateLock<ShardingState>::ShardingStateLock(OperationContext* opCtx, }()) {} template <class ShardingState> -ShardingStateLock<ShardingState> ShardingStateLock<ShardingState>::lock(OperationContext* opCtx, - ShardingState* state) { +ShardingStateLock<ShardingState> ShardingStateLock<ShardingState>::lockShared( + OperationContext* opCtx, ShardingState* state) { return ShardingStateLock(opCtx, state, MODE_IS); } |