diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2020-12-10 16:10:30 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-04 23:28:32 +0000 |
commit | 82dd40f60c55dae12426c08fd7150d79a0e28e23 (patch) | |
tree | e041f9ccd41b2ef861f2b54dcf882b075a581da2 /src | |
parent | 9387b3daca940c1c2b8a7527f62bb7bab42b187f (diff) | |
download | mongo-r4.2.13-rc2.tar.gz |
SERVER-47568 Disable clusterTime gossiping for nodes in unreadable statesr4.2.13-rc2r4.2.13
(cherry picked from commit 024b130c5e66bafd99cf7f899cdef8d23284ef81)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/service_entry_point_common.cpp | 5 | ||||
-rw-r--r-- | src/mongo/rpc/metadata.cpp | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index a5068b83d58..9a4b200d37a 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -332,8 +332,9 @@ void appendClusterAndOperationTime(OperationContext* opCtx, BSONObjBuilder* commandBodyFieldsBob, BSONObjBuilder* metadataBob, LogicalTime startTime) { - if (repl::ReplicationCoordinator::get(opCtx)->getReplicationMode() != - repl::ReplicationCoordinator::modeReplSet || + auto replicationCoordinator = repl::ReplicationCoordinator::get(opCtx); + if (replicationCoordinator->getReplicationMode() != repl::ReplicationCoordinator::modeReplSet || + !replicationCoordinator->getMemberState().readable() || !LogicalClock::get(opCtx)->isEnabled()) { return; } diff --git a/src/mongo/rpc/metadata.cpp b/src/mongo/rpc/metadata.cpp index e3ed093a693..6d9e7581698 100644 --- a/src/mongo/rpc/metadata.cpp +++ b/src/mongo/rpc/metadata.cpp @@ -37,6 +37,7 @@ #include "mongo/db/jsobj.h" #include "mongo/db/logical_clock.h" #include "mongo/db/logical_time_validator.h" +#include "mongo/db/repl/replication_coordinator.h" #include "mongo/rpc/metadata/client_metadata_ismaster.h" #include "mongo/rpc/metadata/config_server_metadata.h" #include "mongo/rpc/metadata/impersonated_user_metadata.h" @@ -93,7 +94,13 @@ void readRequestMetadata(OperationContext* opCtx, const BSONObj& metadataObj, bo uassertStatusOK(TrackingMetadata::readFromMetadata(trackingElem)); auto logicalClock = LogicalClock::get(opCtx); - if (logicalClock && logicalClock->isEnabled()) { + auto replicationCoordinator = repl::ReplicationCoordinator::get(opCtx); + if (logicalClock && logicalClock->isEnabled() && + (!replicationCoordinator || + (replicationCoordinator->getReplicationMode() == + repl::ReplicationCoordinator::modeReplSet && + replicationCoordinator->getMemberState().readable()))) { + auto logicalTimeMetadata = uassertStatusOK(rpc::LogicalTimeMetadata::readFromMetadata(logicalTimeElem)); |