diff options
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)); |