diff options
author | Eric Milkie <milkie@10gen.com> | 2019-01-04 09:31:23 -0500 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2019-01-07 09:26:41 -0500 |
commit | b3b48b80f4b4bdca0b4790185515665881d77a6b (patch) | |
tree | 7908359e8d444cf88165cd7841be2fc13e58283f | |
parent | 428ca4fcc799c43bf1b030798705ed98a5608d51 (diff) | |
download | mongo-b3b48b80f4b4bdca0b4790185515665881d77a6b.tar.gz |
SERVER-38479 allow lock acquisition interruptions in StorageInterface::createCollection and dropCollection
-rw-r--r-- | src/mongo/db/repl/drop_pending_collection_reaper.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_buffer_collection.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_impl.cpp | 3 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/mongo/db/repl/drop_pending_collection_reaper.cpp b/src/mongo/db/repl/drop_pending_collection_reaper.cpp index 7290d0554c3..2e4f639c148 100644 --- a/src/mongo/db/repl/drop_pending_collection_reaper.cpp +++ b/src/mongo/db/repl/drop_pending_collection_reaper.cpp @@ -158,7 +158,13 @@ void DropPendingCollectionReaper::dropCollectionsOlderThan(OperationContext* opC const auto& nss = opTimeAndNamespace.second; log() << "Completing collection drop for " << nss << " with drop optime " << dropOpTime << " (notification optime: " << opTime << ")"; - auto status = _storageInterface->dropCollection(opCtx, nss); + Status status = Status::OK(); + try { + // dropCollection could throw an interrupt exception, since it acquires db locks. + status = _storageInterface->dropCollection(opCtx, nss); + } catch (...) { + status = exceptionToStatus(); + } if (!status.isOK()) { warning() << "Failed to remove drop-pending collection " << nss << " with drop optime " << dropOpTime diff --git a/src/mongo/db/repl/oplog_buffer_collection.cpp b/src/mongo/db/repl/oplog_buffer_collection.cpp index c15b6b33c20..7c28a791b32 100644 --- a/src/mongo/db/repl/oplog_buffer_collection.cpp +++ b/src/mongo/db/repl/oplog_buffer_collection.cpp @@ -357,10 +357,12 @@ BSONObj OplogBufferCollection::_peek_inlock(OperationContext* opCtx, PeekMode pe void OplogBufferCollection::_createCollection(OperationContext* opCtx) { CollectionOptions options; options.temp = true; + UninterruptibleLockGuard noInterrupt(opCtx->lockState()); fassert(40154, _storageInterface->createCollection(opCtx, _nss, options)); } void OplogBufferCollection::_dropCollection(OperationContext* opCtx) { + UninterruptibleLockGuard noInterrupt(opCtx->lockState()); fassert(40155, _storageInterface->dropCollection(opCtx, _nss)); } diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp index 6c4c1adbc57..ac224b641f8 100644 --- a/src/mongo/db/repl/storage_interface_impl.cpp +++ b/src/mongo/db/repl/storage_interface_impl.cpp @@ -118,6 +118,7 @@ StatusWith<int> StorageInterfaceImpl::getRollbackID(OperationContext* opCtx) { } StatusWith<int> StorageInterfaceImpl::initializeRollbackID(OperationContext* opCtx) { + UninterruptibleLockGuard noInterrupt(opCtx->lockState()); auto status = createCollection(opCtx, _rollbackIdNss, CollectionOptions()); if (!status.isOK()) { return status; @@ -431,7 +432,6 @@ Status StorageInterfaceImpl::createCollection(OperationContext* opCtx, const NamespaceString& nss, const CollectionOptions& options) { return writeConflictRetry(opCtx, "StorageInterfaceImpl::createCollection", nss.ns(), [&] { - UninterruptibleLockGuard noInterrupt(opCtx->lockState()); AutoGetOrCreateDb databaseWriteGuard(opCtx, nss.db(), MODE_X); auto db = databaseWriteGuard.getDb(); invariant(db); @@ -454,7 +454,6 @@ Status StorageInterfaceImpl::createCollection(OperationContext* opCtx, Status StorageInterfaceImpl::dropCollection(OperationContext* opCtx, const NamespaceString& nss) { return writeConflictRetry(opCtx, "StorageInterfaceImpl::dropCollection", nss.ns(), [&] { - UninterruptibleLockGuard noInterrupt(opCtx->lockState()); AutoGetDb autoDB(opCtx, nss.db(), MODE_X); if (!autoDB.getDb()) { // Database does not exist - nothing to do. |