diff options
author | Samy Lanka <samy.lanka@mongodb.com> | 2021-05-14 21:06:45 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-17 14:21:33 +0000 |
commit | 23c40392fd939334752d2b20a75e77e89517feea (patch) | |
tree | 73bef4aaa7f16edbb552ec58e8f1b1340db5fea0 /src | |
parent | b8801c6b9c7feb373fa39aac79765e955bd9d79e (diff) | |
download | mongo-23c40392fd939334752d2b20a75e77e89517feea.tar.gz |
SERVER-56963 Prevent secondaries from waiting for write concern when they've taken write locks
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/service_entry_point_mongod.cpp | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index a5c0ea4b2ea..0fb1400aafe 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -1958,6 +1958,7 @@ ReplicationCoordinator::StatusAndDuration ReplicationCoordinatorImpl::awaitRepli "Replication failed for write concern: {writeConcern}, waiting for optime: {opTime}, " "opID: {opID}, all_durable: {allDurable}, progress: {progress}", "Replication failed for write concern", + "status"_attr = redact(status), "writeConcern"_attr = writeConcern.toBSON(), "opTime"_attr = opTime, "opID"_attr = opCtx->getOpID(), diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp index 436f2c0e442..fd48254d9af 100644 --- a/src/mongo/db/service_entry_point_mongod.cpp +++ b/src/mongo/db/service_entry_point_mongod.cpp @@ -134,6 +134,16 @@ public: // wait for write concern on operations the transaction observed. if (opCtx->lockState()->wasGlobalLockTakenForWrite() && !opCtx->inMultiDocumentTransaction()) { + + // Recently stepped down nodes will receive the proper error message because the + // rstlKillOpThread would have already interrupted this thread since it took a lock for + // a write. We should allow standalone nodes to wait for write concern since they might + // be waiting for journaling. + auto replCoord = repl::ReplicationCoordinator::get(opCtx); + if (!replCoord->canAcceptNonLocalWrites() && replCoord->isReplEnabled()) { + return; + } + repl::ReplClientInfo::forClient(opCtx->getClient()).setLastOpToSystemLastOpTime(opCtx); lastOpAfterRun = repl::ReplClientInfo::forClient(opCtx->getClient()).getLastOp(); waitForWriteConcernAndAppendStatus(); |