summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Jin Kang Park <yujin.kang@mongodb.com>2022-11-25 11:02:03 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-25 11:33:03 +0000
commitfe588e79d92b90eaf3a057e8fca78c0b8b8169fd (patch)
tree40d2e3d78e35af0fc2ee4e5fc37c7403b39e8f98
parent161677aca8bae3853e0d000afb65d6655b21fa7b (diff)
downloadmongo-fe588e79d92b90eaf3a057e8fca78c0b8b8169fd.tar.gz
SERVER-68867 Add simplecpplint check for UninterruptibleLockGuard
-rw-r--r--buildscripts/linter/simplecpplint.py12
-rw-r--r--src/mongo/db/catalog/drop_database.cpp6
-rw-r--r--src/mongo/db/catalog/multi_index_block.cpp3
-rw-r--r--src/mongo/db/commands/dbcommands_d.cpp4
-rw-r--r--src/mongo/db/concurrency/d_concurrency.h2
-rw-r--r--src/mongo/db/concurrency/d_concurrency_test.cpp49
-rw-r--r--src/mongo/db/repair.cpp3
-rw-r--r--src/mongo/db/repl/oplog_batcher.cpp2
-rw-r--r--src/mongo/db/repl/oplog_buffer_collection.cpp7
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp2
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp3
-rw-r--r--src/mongo/db/s/collection_sharding_runtime.cpp3
-rw-r--r--src/mongo/db/s/create_collection_coordinator.cpp4
-rw-r--r--src/mongo/db/s/drop_database_coordinator.cpp3
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp3
-rw-r--r--src/mongo/db/s/migration_source_manager.cpp21
-rw-r--r--src/mongo/db/s/migration_util.cpp6
-rw-r--r--src/mongo/db/s/move_primary_source_manager.cpp6
-rw-r--r--src/mongo/db/s/rename_collection_participant_service.cpp3
-rw-r--r--src/mongo/db/s/shard_filtering_metadata_refresh.cpp6
-rw-r--r--src/mongo/db/s/shard_server_op_observer.cpp22
-rw-r--r--src/mongo/db/s/shardsvr_collmod_participant_command.cpp3
-rw-r--r--src/mongo/db/transaction/transaction_participant.cpp8
-rw-r--r--src/mongo/embedded/embedded.cpp3
24 files changed, 118 insertions, 66 deletions
diff --git a/buildscripts/linter/simplecpplint.py b/buildscripts/linter/simplecpplint.py
index a237b4c84b7..959f4781504 100644
--- a/buildscripts/linter/simplecpplint.py
+++ b/buildscripts/linter/simplecpplint.py
@@ -61,6 +61,7 @@ _RE_UNSTRUCTURED_LOG = re.compile(r'\blogd\s*\(')
_RE_STD_OPTIONAL = re.compile(r'\bstd::optional\b')
_RE_TRACING_SUPPORT = re.compile(r'\bTracerProvider::(get|initialize)\b')
_RE_COLLECTION_SHARDING_RUNTIME = re.compile(r'\bCollectionShardingRuntime\b')
+_RE_UNINTERRUPTIBLE_LOCK_GUARD = re.compile(r'\bUninterruptibleLockGuard\s+.+\s*;')
_RE_GENERIC_FCV_COMMENT = re.compile(r'\(Generic FCV reference\):')
GENERIC_FCV = [
@@ -155,6 +156,7 @@ class Linter:
self._check_for_std_optional(linenum)
self._check_for_tracing_support(linenum)
self._check_for_collection_sharding_runtime(linenum)
+ self._check_for_uninterruptible_lock_guard(linenum)
# Relax the rule of commenting generic FCV references for files directly related to FCV
# implementations.
@@ -300,6 +302,16 @@ class Linter:
'CollectionShardingRuntime outside of mongo/db/s/; use CollectionShardingState '
'instead; see src/mongo/db/s/collection_sharding_state.h for details.')
+ def _check_for_uninterruptible_lock_guard(self, linenum):
+ line = self.clean_lines[linenum]
+ if _RE_UNINTERRUPTIBLE_LOCK_GUARD.search(line):
+ self._error(
+ linenum, 'mongodb/uninterruptible_lock_guard',
+ 'Potentially incorrect use of UninterruptibleLockGuard, '
+ 'the programming model inside MongoDB requires that all operations be interruptible. '
+ 'Review with care and if the use is warranted, add NOLINT and a comment explaining why.'
+ )
+
def _license_error(self, linenum, msg, category='legal/license'):
style_url = 'https://github.com/mongodb/mongo/wiki/Server-Code-Style'
self._error(linenum, category, '{} See {}'.format(msg, style_url))
diff --git a/src/mongo/db/catalog/drop_database.cpp b/src/mongo/db/catalog/drop_database.cpp
index b58a27ae5be..4e2a3414f12 100644
--- a/src/mongo/db/catalog/drop_database.cpp
+++ b/src/mongo/db/catalog/drop_database.cpp
@@ -188,7 +188,8 @@ Status _dropDatabase(OperationContext* opCtx, const DatabaseName& dbName, bool a
// there is a replica state change that kills this operation while the locks were
// yielded.
ScopeGuard dropPendingGuardWhileUnlocked([dbName, opCtx, &dropPendingGuard] {
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71610): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
AutoGetDb autoDB(opCtx, dbName, MODE_IX);
if (auto db = autoDB.getDb()) {
db->setDropPending(opCtx, false);
@@ -304,7 +305,8 @@ Status _dropDatabase(OperationContext* opCtx, const DatabaseName& dbName, bool a
// any errors while we await the replication of any collection drops and then reacquire the
// locks (which can throw) needed to finish the drop database.
ScopeGuard dropPendingGuardWhileUnlocked([dbName, opCtx] {
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71610): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
AutoGetDb autoDB(opCtx, dbName, MODE_IX);
if (auto db = autoDB.getDb()) {
diff --git a/src/mongo/db/catalog/multi_index_block.cpp b/src/mongo/db/catalog/multi_index_block.cpp
index 9e26cf7d4da..82f1d7fb6b2 100644
--- a/src/mongo/db/catalog/multi_index_block.cpp
+++ b/src/mongo/db/catalog/multi_index_block.cpp
@@ -1023,7 +1023,8 @@ void MultiIndexBlock::abortWithoutCleanup(OperationContext* opCtx,
const CollectionPtr& collection,
bool isResumable) {
invariant(!_buildIsCleanedUp);
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71610): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
// Lock if it's not already locked, to ensure storage engine cannot be destructed out from
// underneath us.
boost::optional<Lock::GlobalLock> lk;
diff --git a/src/mongo/db/commands/dbcommands_d.cpp b/src/mongo/db/commands/dbcommands_d.cpp
index 5ad0adf46c5..d4fd321c0b6 100644
--- a/src/mongo/db/commands/dbcommands_d.cpp
+++ b/src/mongo/db/commands/dbcommands_d.cpp
@@ -330,7 +330,9 @@ public:
// and those helpers may throw if something has changed since the last time we took
// a lock. For example, AutoGetCollection will throw if this namespace has since
// turned into a view and AutoGetDb will throw if the database version is stale.
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+
+ // TODO (SERVER-71441): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
Lock::DBLock dbLock(opCtx, nss.dbName(), MODE_IS);
invariant(dbLock.isLocked(),
"Expected lock acquisition to succeed due to UninterruptibleLockGuard");
diff --git a/src/mongo/db/concurrency/d_concurrency.h b/src/mongo/db/concurrency/d_concurrency.h
index b93cb5e9b72..324a0190d42 100644
--- a/src/mongo/db/concurrency/d_concurrency.h
+++ b/src/mongo/db/concurrency/d_concurrency.h
@@ -152,7 +152,7 @@ public:
// returned in the locked state so the acquisition below must be guaranteed to always
// succeed.
invariant(_opCtx);
- UninterruptibleLockGuard ulg(_opCtx->lockState());
+ UninterruptibleLockGuard ulg(_opCtx->lockState()); // NOLINT.
_lock(MODE_X);
}
diff --git a/src/mongo/db/concurrency/d_concurrency_test.cpp b/src/mongo/db/concurrency/d_concurrency_test.cpp
index 32d328516b1..73d57b1c78d 100644
--- a/src/mongo/db/concurrency/d_concurrency_test.cpp
+++ b/src/mongo/db/concurrency/d_concurrency_test.cpp
@@ -1043,12 +1043,13 @@ TEST_F(DConcurrencyTestFixture, GlobalLockWaitIsNotInterruptibleWithLockGuard) {
boost::optional<Lock::GlobalLock> globalLock = Lock::GlobalLock(opCtx1, MODE_X);
// Killing the lock wait should not interrupt it.
- auto result = runTaskAndKill(opCtx2,
- [&]() {
- UninterruptibleLockGuard noInterrupt(opCtx2->lockState());
- Lock::GlobalLock g(opCtx2, MODE_S);
- },
- [&]() { globalLock.reset(); });
+ auto result =
+ runTaskAndKill(opCtx2,
+ [&]() {
+ UninterruptibleLockGuard noInterrupt(opCtx2->lockState()); // NOLINT.
+ Lock::GlobalLock g(opCtx2, MODE_S);
+ },
+ [&]() { globalLock.reset(); });
// Should not throw an exception.
result.get();
}
@@ -1067,7 +1068,7 @@ TEST_F(DConcurrencyTestFixture, DBLockWaitIsNotInterruptibleWithLockGuard) {
auto result =
runTaskAndKill(opCtx2,
[&]() {
- UninterruptibleLockGuard noInterrupt(opCtx2->lockState());
+ UninterruptibleLockGuard noInterrupt(opCtx2->lockState()); // NOLINT.
Lock::DBLock d(opCtx2, DatabaseName(boost::none, "db"), MODE_S);
},
[&] { dbLock.reset(); });
@@ -1664,16 +1665,16 @@ TEST_F(DConcurrencyTestFixture, TicketAcquireWithMaxDeadlineRespectsUninterrupti
boost::optional<Lock::GlobalRead> R2;
// Block until a ticket is available.
- auto result =
- runTaskAndKill(opCtx2,
- [&] {
- UninterruptibleLockGuard noInterrupt(opCtx2->lockState());
- R2.emplace(opCtx2, Date_t::max(), Lock::InterruptBehavior::kThrow);
- },
- [&] {
- // Relase the only ticket available to unblock the other thread.
- R1.reset();
- });
+ auto result = runTaskAndKill(
+ opCtx2,
+ [&] {
+ UninterruptibleLockGuard noInterrupt(opCtx2->lockState()); // NOLINT.
+ R2.emplace(opCtx2, Date_t::max(), Lock::InterruptBehavior::kThrow);
+ },
+ [&] {
+ // Relase the only ticket available to unblock the other thread.
+ R1.reset();
+ });
result.get(); // This should not throw.
ASSERT(R2->isLocked());
@@ -1757,7 +1758,7 @@ TEST_F(DConcurrencyTestFixture, GlobalLockInInterruptedContextRespectsUninterrup
opCtx->markKilled();
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
Lock::GlobalRead globalReadLock(
opCtx, Date_t::now(), Lock::InterruptBehavior::kThrow); // Does not throw.
}
@@ -1797,7 +1798,7 @@ TEST_F(DConcurrencyTestFixture, DBLockInInterruptedContextRespectsUninterruptibl
opCtx->markKilled();
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
Lock::DBLock dbWriteLock(opCtx, DatabaseName(boost::none, "db"), MODE_X); // Does not throw.
}
@@ -1883,7 +1884,7 @@ TEST_F(DConcurrencyTestFixture, CollectionLockInInterruptedContextRespectsUninte
opCtx->markKilled();
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
Lock::CollectionLock collLock(opCtx, NamespaceString("db.coll"), MODE_IX); // Does not throw.
}
@@ -2325,7 +2326,7 @@ TEST_F(DConcurrencyTestFixture, FailPointInLockDoesNotFailUninterruptibleGlobalN
// MODE_S attempt.
stdx::thread t2([&]() {
- UninterruptibleLockGuard noInterrupt(&locker2);
+ UninterruptibleLockGuard noInterrupt(&locker2); // NOLINT.
locker2.lockGlobal(opCtx.get(), MODE_S);
});
@@ -2342,7 +2343,7 @@ TEST_F(DConcurrencyTestFixture, FailPointInLockDoesNotFailUninterruptibleGlobalN
// MODE_X attempt.
stdx::thread t3([&]() {
- UninterruptibleLockGuard noInterrupt(&locker3);
+ UninterruptibleLockGuard noInterrupt(&locker3); // NOLINT.
locker3.lockGlobal(opCtx.get(), MODE_X);
});
@@ -2374,7 +2375,7 @@ TEST_F(DConcurrencyTestFixture, FailPointInLockDoesNotFailUninterruptibleNonInte
// MODE_S attempt.
stdx::thread t2([&]() {
- UninterruptibleLockGuard noInterrupt(&locker2);
+ UninterruptibleLockGuard noInterrupt(&locker2); // NOLINT.
locker2.lockGlobal(opCtx.get(), MODE_IS);
locker2.lock(resId, MODE_S);
});
@@ -2393,7 +2394,7 @@ TEST_F(DConcurrencyTestFixture, FailPointInLockDoesNotFailUninterruptibleNonInte
// MODE_X attempt.
stdx::thread t3([&]() {
- UninterruptibleLockGuard noInterrupt(&locker3);
+ UninterruptibleLockGuard noInterrupt(&locker3); // NOLINT.
locker3.lockGlobal(opCtx.get(), MODE_IX);
locker3.lock(resId, MODE_X);
});
diff --git a/src/mongo/db/repair.cpp b/src/mongo/db/repair.cpp
index 0a6dade23af..9b64e51f1d4 100644
--- a/src/mongo/db/repair.cpp
+++ b/src/mongo/db/repair.cpp
@@ -169,7 +169,8 @@ Status repairDatabase(OperationContext* opCtx, StorageEngine* engine, const Data
try {
// Ensure that we don't trigger an exception when attempting to take locks.
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71610): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
// Restore oplog Collection pointer cache.
repl::acquireOplogCollectionForLogging(opCtx);
diff --git a/src/mongo/db/repl/oplog_batcher.cpp b/src/mongo/db/repl/oplog_batcher.cpp
index f75c77f8845..ea6f86715a3 100644
--- a/src/mongo/db/repl/oplog_batcher.cpp
+++ b/src/mongo/db/repl/oplog_batcher.cpp
@@ -314,7 +314,7 @@ void OplogBatcher::_run(StorageInterface* storageInterface) {
// UninterruptibleLockGuard in batch application because the only cause of
// interruption would be shutdown, and the ReplBatcher thread has its own shutdown
// handling.
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
// Locks the oplog to check its max size, do this in the UninterruptibleLockGuard.
batchLimits.bytes = getBatchLimitOplogBytes(opCtx.get(), storageInterface);
diff --git a/src/mongo/db/repl/oplog_buffer_collection.cpp b/src/mongo/db/repl/oplog_buffer_collection.cpp
index b31fa1cf96d..99dd1429751 100644
--- a/src/mongo/db/repl/oplog_buffer_collection.cpp
+++ b/src/mongo/db/repl/oplog_buffer_collection.cpp
@@ -459,7 +459,9 @@ void OplogBufferCollection::_createCollection(OperationContext* opCtx) {
// This oplog-like collection will benefit from clustering by _id to reduce storage engine
// overhead and improve _id query efficiency.
options.clusteredIndex = clustered_util::makeDefaultClusteredIdIndex();
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+
+ // TODO (SERVER-71443): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
auto status = _storageInterface->createCollection(opCtx, _nss, options);
if (status.code() == ErrorCodes::NamespaceExists)
return;
@@ -467,7 +469,8 @@ void OplogBufferCollection::_createCollection(OperationContext* opCtx) {
}
void OplogBufferCollection::_dropCollection(OperationContext* opCtx) {
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71443): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
uassertStatusOK(_storageInterface->dropCollection(opCtx, _nss));
}
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 57c162eac46..4c589478c48 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -2854,7 +2854,7 @@ void ReplicationCoordinatorImpl::stepDown(OperationContext* opCtx,
// attempt, we might as well spend whatever time we need to acquire it now. For
// the same reason, we also disable lock acquisition interruption, to guarantee that
// we get the lock eventually.
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
// Since we have released the RSTL lock at this point, there can be some read
// operations sneaked in here, that might hold global lock in S mode or blocked on
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 98dd971cb8d..93096ff7b95 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -128,7 +128,8 @@ StatusWith<int> StorageInterfaceImpl::getRollbackID(OperationContext* opCtx) {
}
StatusWith<int> StorageInterfaceImpl::initializeRollbackID(OperationContext* opCtx) {
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71443): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
auto status = createCollection(opCtx, _rollbackIdNss, CollectionOptions());
if (!status.isOK()) {
return status;
diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp
index 90bb2e00fa0..51a4f6ac5a6 100644
--- a/src/mongo/db/s/collection_sharding_runtime.cpp
+++ b/src/mongo/db/s/collection_sharding_runtime.cpp
@@ -577,7 +577,8 @@ CollectionCriticalSection::CollectionCriticalSection(OperationContext* opCtx,
}
CollectionCriticalSection::~CollectionCriticalSection() {
- UninterruptibleLockGuard noInterrupt(_opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(_opCtx->lockState()); // NOLINT.
AutoGetCollection autoColl(_opCtx, _nss, MODE_IX);
auto scopedCsr = CollectionShardingRuntime::assertCollectionLockedAndAcquire(
_opCtx, _nss, CSRAcquisitionMode::kExclusive);
diff --git a/src/mongo/db/s/create_collection_coordinator.cpp b/src/mongo/db/s/create_collection_coordinator.cpp
index 8af984204a9..5b4b22a3b6d 100644
--- a/src/mongo/db/s/create_collection_coordinator.cpp
+++ b/src/mongo/db/s/create_collection_coordinator.cpp
@@ -1290,7 +1290,9 @@ void CreateCollectionCoordinator::_commit(OperationContext* opCtx,
// If the refresh fails, then set the shard version to UNKNOWN and let a future
// operation to refresh the metadata.
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
AutoGetCollection autoColl(opCtx, nss(), MODE_IX);
CollectionShardingRuntime::assertCollectionLockedAndAcquire(
opCtx, nss(), CSRAcquisitionMode::kExclusive)
diff --git a/src/mongo/db/s/drop_database_coordinator.cpp b/src/mongo/db/s/drop_database_coordinator.cpp
index 5b93fad8cdc..157d5a32ec5 100644
--- a/src/mongo/db/s/drop_database_coordinator.cpp
+++ b/src/mongo/db/s/drop_database_coordinator.cpp
@@ -163,7 +163,8 @@ public:
}
~ScopedDatabaseCriticalSection() {
- UninterruptibleLockGuard guard(_opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard guard(_opCtx->lockState()); // NOLINT.
// TODO SERVER-67438 Once ScopedDatabaseCriticalSection holds a DatabaseName obj, use dbName
// directly
DatabaseName databaseName(boost::none, _dbName);
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
index 18f50099a09..6607d2b2f33 100644
--- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
+++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
@@ -212,7 +212,8 @@ void LogTransactionOperationsForShardingHandler::commit(OperationContext* opCtx,
const auto& nss = stmt.getNss();
auto opCtx = cc().getOperationContext();
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
auto scopedCss = CollectionShardingRuntime::assertCollectionLockedAndAcquire(
opCtx, nss, CSRAcquisitionMode::kShared);
diff --git a/src/mongo/db/s/migration_source_manager.cpp b/src/mongo/db/s/migration_source_manager.cpp
index 5ea3422c2ef..da33366e8a8 100644
--- a/src/mongo/db/s/migration_source_manager.cpp
+++ b/src/mongo/db/s/migration_source_manager.cpp
@@ -180,7 +180,8 @@ MigrationSourceManager::MigrationSourceManager(OperationContext* opCtx,
// Snapshot the committed metadata from the time the migration starts
const auto [collectionMetadata, collectionIndexInfo, collectionUUID] = [&] {
- UninterruptibleLockGuard noInterrupt(_opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(_opCtx->lockState()); // NOLINT.
AutoGetCollection autoColl(_opCtx, nss(), MODE_IS);
auto scopedCsr = CollectionShardingRuntime::assertCollectionLockedAndAcquire(
opCtx, nss(), CSRAcquisitionMode::kExclusive);
@@ -480,7 +481,8 @@ void MigrationSourceManager::commitChunkMetadataOnConfig() {
if (!migrationCommitStatus.isOK()) {
{
- UninterruptibleLockGuard noInterrupt(_opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(_opCtx->lockState()); // NOLINT.
AutoGetCollection autoColl(_opCtx, nss(), MODE_IX);
CollectionShardingRuntime::assertCollectionLockedAndAcquire(
_opCtx, nss(), CSRAcquisitionMode::kExclusive)
@@ -519,7 +521,8 @@ void MigrationSourceManager::commitChunkMetadataOnConfig() {
"migrationId"_attr = _coordinator->getMigrationId(),
"error"_attr = redact(ex));
{
- UninterruptibleLockGuard noInterrupt(_opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(_opCtx->lockState()); // NOLINT.
AutoGetCollection autoColl(_opCtx, nss(), MODE_IX);
CollectionShardingRuntime::assertCollectionLockedAndAcquire(
_opCtx, nss(), CSRAcquisitionMode::kExclusive)
@@ -637,7 +640,8 @@ SharedSemiFuture<void> MigrationSourceManager::abort() {
CollectionMetadata MigrationSourceManager::_getCurrentMetadataAndCheckEpoch() {
auto metadata = [&] {
- UninterruptibleLockGuard noInterrupt(_opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(_opCtx->lockState()); // NOLINT.
AutoGetCollection autoColl(_opCtx, _args.getCommandParameter(), MODE_IS);
auto scopedCsr = CollectionShardingRuntime::assertCollectionLockedAndAcquire(
_opCtx, _args.getCommandParameter(), CSRAcquisitionMode::kShared);
@@ -665,7 +669,8 @@ void MigrationSourceManager::_cleanup(bool completeMigration) noexcept {
auto cloneDriver = [&]() {
// Unregister from the collection's sharding state and exit the migration critical section.
- UninterruptibleLockGuard noInterrupt(_opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(_opCtx->lockState()); // NOLINT.
AutoGetCollection autoColl(_opCtx, nss(), MODE_IX);
auto scopedCsr = CollectionShardingRuntime::assertCollectionLockedAndAcquire(
_opCtx, nss(), CSRAcquisitionMode::kExclusive);
@@ -759,7 +764,8 @@ void MigrationSourceManager::_cleanup(bool completeMigration) noexcept {
"migrationId"_attr = _coordinator->getMigrationId());
// Something went really wrong when completing the migration just unset the metadata and let
// the next op to recover.
- UninterruptibleLockGuard noInterrupt(_opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(_opCtx->lockState()); // NOLINT.
AutoGetCollection autoColl(_opCtx, nss(), MODE_IX);
CollectionShardingRuntime::assertCollectionLockedAndAcquire(
_opCtx, nss(), CSRAcquisitionMode::kExclusive)
@@ -785,7 +791,8 @@ MigrationSourceManager::ScopedRegisterer::ScopedRegisterer(MigrationSourceManage
}
MigrationSourceManager::ScopedRegisterer::~ScopedRegisterer() {
- UninterruptibleLockGuard noInterrupt(_msm->_opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(_msm->_opCtx->lockState()); // NOLINT.
AutoGetCollection autoColl(_msm->_opCtx, _msm->_args.getCommandParameter(), MODE_IX);
auto scopedCsr = CollectionShardingRuntime::assertCollectionLockedAndAcquire(
_msm->_opCtx, _msm->_args.getCommandParameter(), CSRAcquisitionMode::kExclusive);
diff --git a/src/mongo/db/s/migration_util.cpp b/src/mongo/db/s/migration_util.cpp
index 89b1a5d8f3a..2a821beb1f8 100644
--- a/src/mongo/db/s/migration_util.cpp
+++ b/src/mongo/db/s/migration_util.cpp
@@ -690,7 +690,8 @@ void notifyChangeStreamsOnRecipientFirstChunk(OperationContext* opCtx,
auto const serviceContext = opCtx->getClient()->getServiceContext();
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
AutoGetOplog oplogWrite(opCtx, OplogAccessMode::kWrite);
writeConflictRetry(
opCtx, "migrateChunkToNewShard", NamespaceString::kRsOplogNamespace.ns(), [&] {
@@ -722,7 +723,8 @@ void notifyChangeStreamsOnDonorLastChunk(OperationContext* opCtx,
auto const serviceContext = opCtx->getClient()->getServiceContext();
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
AutoGetOplog oplogWrite(opCtx, OplogAccessMode::kWrite);
writeConflictRetry(
opCtx, "migrateLastChunkFromShard", NamespaceString::kRsOplogNamespace.ns(), [&] {
diff --git a/src/mongo/db/s/move_primary_source_manager.cpp b/src/mongo/db/s/move_primary_source_manager.cpp
index 350198d53ce..c4df7775f6a 100644
--- a/src/mongo/db/s/move_primary_source_manager.cpp
+++ b/src/mongo/db/s/move_primary_source_manager.cpp
@@ -276,7 +276,8 @@ Status MovePrimarySourceManager::commitOnConfig(OperationContext* opCtx) {
// metadata for this database, forcing subsequent callers to do a full refresh. Check if
// this node can accept writes for this collection as a proxy for it being primary.
if (!validateStatus.isOK()) {
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
AutoGetDb autoDb(opCtx, getNss().dbName(), MODE_IX);
if (!autoDb.getDb()) {
@@ -504,7 +505,8 @@ void MovePrimarySourceManager::_cleanup(OperationContext* opCtx) {
{
// Unregister from the database's sharding state if we're still registered.
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
AutoGetDb autoDb(opCtx, getNss().dbName(), MODE_IX);
auto scopedDss = DatabaseShardingState::assertDbLockedAndAcquire(
diff --git a/src/mongo/db/s/rename_collection_participant_service.cpp b/src/mongo/db/s/rename_collection_participant_service.cpp
index 746e7beb563..c0439a2c39d 100644
--- a/src/mongo/db/s/rename_collection_participant_service.cpp
+++ b/src/mongo/db/s/rename_collection_participant_service.cpp
@@ -73,7 +73,8 @@ void dropCollectionLocally(OperationContext* opCtx, const NamespaceString& nss)
}
void clearFilteringMetadata(OperationContext* opCtx, const NamespaceString& nss) {
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
Lock::DBLock dbLock(opCtx, nss.dbName(), MODE_IX);
Lock::CollectionLock collLock(opCtx, nss, MODE_IX);
CollectionShardingRuntime::assertCollectionLockedAndAcquire(
diff --git a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
index d7d5050b75b..dbcc1426416 100644
--- a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
+++ b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
@@ -120,7 +120,8 @@ Status refreshDbMetadata(OperationContext* opCtx,
invariant(ShardingState::get(opCtx)->canAcceptShardedCommands());
ScopeGuard resetRefreshFutureOnError([&] {
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
Lock::DBLock dbLock(opCtx, dbName, MODE_IX);
auto scopedDss = DatabaseShardingState::assertDbLockedAndAcquire(
@@ -383,7 +384,8 @@ SharedSemiFuture<void> recoverRefreshCollectionPlacementVersion(
boost::optional<CollectionMetadata> currentMetadataToInstall;
ON_BLOCK_EXIT([&] {
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
// A view can potentially be created after spawning a thread to recover nss's shard
// version. It is then ok to lock views in order to clear filtering metadata.
//
diff --git a/src/mongo/db/s/shard_server_op_observer.cpp b/src/mongo/db/s/shard_server_op_observer.cpp
index 64d453a3bf3..459512a697e 100644
--- a/src/mongo/db/s/shard_server_op_observer.cpp
+++ b/src/mongo/db/s/shard_server_op_observer.cpp
@@ -90,7 +90,8 @@ public:
// Force subsequent uses of the namespace to refresh the filtering metadata so they can
// synchronize with any work happening on the primary (e.g., migration critical section).
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
auto scopedCss = CollectionShardingRuntime::assertCollectionLockedAndAcquire(
opCtx, _nss, CSRAcquisitionMode::kExclusive);
if (_droppingCollection)
@@ -300,8 +301,8 @@ void ShardServerOpObserver::onInserts(OperationContext* opCtx,
if (!isStandaloneOrPrimary(opCtx)) {
lockDbIfNotPrimary.emplace(opCtx, insertedNss.dbName(), MODE_IX);
}
-
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
auto scopedDss = DatabaseShardingState::assertDbLockedAndAcquire(
opCtx, insertedNss.dbName(), DSSAcquisitionMode::kExclusive);
scopedDss->enterCriticalSectionCatchUpPhase(opCtx, reason);
@@ -316,7 +317,8 @@ void ShardServerOpObserver::onInserts(OperationContext* opCtx,
auto_get_collection::ViewMode::kViewsPermitted));
}
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
auto scopedCsr = CollectionShardingRuntime::assertCollectionLockedAndAcquire(
opCtx, insertedNss, CSRAcquisitionMode::kExclusive);
scopedCsr->enterCriticalSectionCatchUpPhase(reason);
@@ -470,7 +472,8 @@ void ShardServerOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateE
lockDbIfNotPrimary.emplace(opCtx, updatedNss.dbName(), MODE_IX);
}
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
auto scopedDss = DatabaseShardingState::assertDbLockedAndAcquire(
opCtx, updatedNss.dbName(), DSSAcquisitionMode::kExclusive);
scopedDss->enterCriticalSectionCommitPhase(opCtx, reason);
@@ -485,7 +488,8 @@ void ShardServerOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateE
auto_get_collection::ViewMode::kViewsPermitted));
}
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
auto scopedCsr = CollectionShardingRuntime::assertCollectionLockedAndAcquire(
opCtx, updatedNss, CSRAcquisitionMode::kExclusive);
scopedCsr->enterCriticalSectionCommitPhase(reason);
@@ -662,7 +666,8 @@ void ShardServerOpObserver::onDelete(OperationContext* opCtx,
lockDbIfNotPrimary.emplace(opCtx, deletedNss.dbName(), MODE_IX);
}
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
auto scopedDss = DatabaseShardingState::assertDbLockedAndAcquire(
opCtx, deletedNss.dbName(), DSSAcquisitionMode::kExclusive);
@@ -684,7 +689,8 @@ void ShardServerOpObserver::onDelete(OperationContext* opCtx,
auto_get_collection::ViewMode::kViewsPermitted));
}
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
auto scopedCsr = CollectionShardingRuntime::assertCollectionLockedAndAcquire(
opCtx, deletedNss, CSRAcquisitionMode::kExclusive);
diff --git a/src/mongo/db/s/shardsvr_collmod_participant_command.cpp b/src/mongo/db/s/shardsvr_collmod_participant_command.cpp
index f4853d88a15..b3ff0e66e22 100644
--- a/src/mongo/db/s/shardsvr_collmod_participant_command.cpp
+++ b/src/mongo/db/s/shardsvr_collmod_participant_command.cpp
@@ -100,7 +100,8 @@ public:
} catch (const DBException&) {
// If the refresh fails, then set the shard version to UNKNOWN and let a future
// operation to refresh the metadata.
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71444): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
AutoGetCollection autoColl(opCtx, bucketNs, MODE_IX);
CollectionShardingRuntime::assertCollectionLockedAndAcquire(
opCtx, bucketNs, CSRAcquisitionMode::kExclusive)
diff --git a/src/mongo/db/transaction/transaction_participant.cpp b/src/mongo/db/transaction/transaction_participant.cpp
index caa49b9e694..ebcce4f2a83 100644
--- a/src/mongo/db/transaction/transaction_participant.cpp
+++ b/src/mongo/db/transaction/transaction_participant.cpp
@@ -1599,7 +1599,8 @@ Timestamp TransactionParticipant::Participant::prepareTransaction(
// of RSTL lock inside abortTransaction will be no-op since we already have it.
// This abortGuard gets dismissed before we release the RSTL while transitioning to
// prepared.
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71610): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
abortTransaction(opCtx);
} catch (...) {
// It is illegal for aborting a prepared transaction to fail for any reason, so we crash
@@ -1886,7 +1887,8 @@ void TransactionParticipant::Participant::commitPreparedTransaction(
unlockGuard.dismiss();
// Once entering "committing with prepare" we cannot throw an exception.
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ // TODO (SERVER-71610): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
opCtx->recoveryUnit()->setCommitTimestamp(commitTimestamp);
// On secondary, we generate a fake empty oplog slot, since it's not used by opObserver.
@@ -2092,7 +2094,7 @@ void TransactionParticipant::Participant::_abortActiveTransaction(
try {
// If we need to write an abort oplog entry, this function can no longer be interrupted.
- UninterruptibleLockGuard noInterrupt(opCtx->lockState());
+ UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // NOLINT.
// Write the abort oplog entry. This must be done after aborting the storage
// transaction, so that the lock state is reset, and there is no max lock timeout on the
diff --git a/src/mongo/embedded/embedded.cpp b/src/mongo/embedded/embedded.cpp
index a303ab0e4c9..589206f2ad6 100644
--- a/src/mongo/embedded/embedded.cpp
+++ b/src/mongo/embedded/embedded.cpp
@@ -165,7 +165,8 @@ void shutdown(ServiceContext* srvContext) {
// Close all open databases, shutdown storage engine and run all deinitializers.
auto shutdownOpCtx = serviceContext->makeOperationContext(client);
{
- UninterruptibleLockGuard noInterrupt(shutdownOpCtx->lockState());
+ // TODO (SERVER-71610): Fix to be interruptible or document exception.
+ UninterruptibleLockGuard noInterrupt(shutdownOpCtx->lockState()); // NOLINT.
Lock::GlobalLock lk(shutdownOpCtx.get(), MODE_X);
auto databaseHolder = DatabaseHolder::get(shutdownOpCtx.get());
databaseHolder->closeAll(shutdownOpCtx.get());