diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2021-08-06 19:51:35 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-08-10 15:19:26 +0000 |
commit | 64dd4524434f617b480e742e8dc421cccd8231fa (patch) | |
tree | a7d9be67c9893669fb1c0304a3e6ce0a13140c05 /src/mongo/db/repl | |
parent | 18f6ad80da5dd6225224d11914905fb1851b4833 (diff) | |
download | mongo-64dd4524434f617b480e742e8dc421cccd8231fa.tar.gz |
SERVER-59074 Do not acquire storage tickets just to set/wait on oplog visibility
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_external_state_impl.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_impl.cpp | 9 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp index 36c740ffa57..45a54c4d356 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp @@ -462,15 +462,14 @@ Status ReplicationCoordinatorExternalStateImpl::initializeReplSetStorage(Operati const auto msgObj = BSON("msg" << kInitiatingSetMsg); _service->getOpObserver()->onOpMessage(opCtx, msgObj); wuow.commit(); - // ReplSetTest assumes that immediately after the replSetInitiate - // command returns, it can allow other nodes to initial sync with - // no retries and they will succeed. Unfortunately, initial sync - // will fail if it finds its sync source has an empty oplog. - // Thus, we need to wait here until the seed document is visible - // in our oplog. - _storageInterface->waitForAllEarlierOplogWritesToBeVisible(opCtx); }); + // ReplSetTest assumes that immediately after the replSetInitiate command returns, it can + // allow other nodes to initial sync with no retries and they will succeed. Unfortunately, + // initial sync will fail if it finds its sync source has an empty oplog. Thus, we need to + // wait here until the seed document is visible in our oplog. + _storageInterface->waitForAllEarlierOplogWritesToBeVisible(opCtx); + // Take an unstable checkpoint to ensure that the FCV document is persisted to disk. opCtx->recoveryUnit()->waitUntilUnjournaledWritesDurable(opCtx, false /* stableCheckpoint */); diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp index e3c399ae252..7263afc9127 100644 --- a/src/mongo/db/repl/storage_interface_impl.cpp +++ b/src/mongo/db/repl/storage_interface_impl.cpp @@ -52,6 +52,7 @@ #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/client.h" #include "mongo/db/concurrency/d_concurrency.h" +#include "mongo/db/concurrency/lock_state.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/curop.h" #include "mongo/db/db_raii.h" @@ -1443,6 +1444,10 @@ Status StorageInterfaceImpl::isAdminDbValid(OperationContext* opCtx) { void StorageInterfaceImpl::waitForAllEarlierOplogWritesToBeVisible(OperationContext* opCtx, bool primaryOnly) { + // Waiting for oplog writes to be visible in the oplog does not use any storage engine resources + // and must skip ticket acquisition to avoid deadlocks with updating oplog visibility. + SkipTicketAcquisitionForLock skipTicketAcquisition(opCtx); + AutoGetOplog oplogRead(opCtx, OplogAccessMode::kRead); if (primaryOnly && !repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesForDatabase(opCtx, "admin")) @@ -1455,6 +1460,10 @@ void StorageInterfaceImpl::waitForAllEarlierOplogWritesToBeVisible(OperationCont void StorageInterfaceImpl::oplogDiskLocRegister(OperationContext* opCtx, const Timestamp& ts, bool orderedCommit) { + // Setting the oplog visibility does not use any storage engine resources and must skip ticket + // acquisition to avoid deadlocks with updating oplog visibility. + SkipTicketAcquisitionForLock skipTicketAcquisition(opCtx); + AutoGetOplog oplogRead(opCtx, OplogAccessMode::kRead); fassert(28557, oplogRead.getCollection()->getRecordStore()->oplogDiskLocRegister( |