diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2018-01-04 17:32:21 -0500 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2018-01-23 09:57:56 -0500 |
commit | a98d497c957dc2da7d29c37be9809ace992ef946 (patch) | |
tree | 17191166815defa371bfead2ddeb022b752f03a6 /src/mongo/db/read_concern.cpp | |
parent | ad0ab27807a29e025b36a82ede139c975ad65cfb (diff) | |
download | mongo-a98d497c957dc2da7d29c37be9809ace992ef946.tar.gz |
SERVER-32517 Parse readConcern snapshot and atClusterTime
Diffstat (limited to 'src/mongo/db/read_concern.cpp')
-rw-r--r-- | src/mongo/db/read_concern.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/mongo/db/read_concern.cpp b/src/mongo/db/read_concern.cpp index 44196c98dcf..57ae829011c 100644 --- a/src/mongo/db/read_concern.cpp +++ b/src/mongo/db/read_concern.cpp @@ -233,7 +233,19 @@ Status waitForReadConcern(OperationContext* opCtx, } } - auto afterClusterTime = readConcernArgs.getArgsClusterTime(); + if (readConcernArgs.getLevel() == repl::ReadConcernLevel::kSnapshotReadConcern) { + if (replCoord->getReplicationMode() != repl::ReplicationCoordinator::modeReplSet) { + return {ErrorCodes::NotAReplicaSet, + "node needs to be a replica set member to use readConcern: snapshot"}; + } + + if (!replCoord->isV1ElectionProtocol()) { + return {ErrorCodes::IncompatibleElectionProtocol, + "Replica sets running protocol version 0 do not support readConcern: snapshot"}; + } + } + + auto afterClusterTime = readConcernArgs.getArgsAfterClusterTime(); if (afterClusterTime) { if (!allowAfterClusterTime) { return {ErrorCodes::InvalidOptions, "afterClusterTime is not allowed for this command"}; @@ -246,11 +258,6 @@ Status waitForReadConcern(OperationContext* opCtx, } } - auto pointInTime = readConcernArgs.getArgsPointInTime(); - if (pointInTime) { - fassertStatusOK(39345, opCtx->recoveryUnit()->selectSnapshot(pointInTime->asTimestamp())); - } - if (!readConcernArgs.isEmpty()) { if (replCoord->isReplEnabled() && afterClusterTime) { auto status = makeNoopWriteIfNeeded(opCtx, *afterClusterTime); @@ -268,6 +275,11 @@ Status waitForReadConcern(OperationContext* opCtx, } } + auto pointInTime = readConcernArgs.getArgsAtClusterTime(); + if (pointInTime) { + fassertStatusOK(39345, opCtx->recoveryUnit()->selectSnapshot(pointInTime->asTimestamp())); + } + if (readConcernArgs.getLevel() == repl::ReadConcernLevel::kMajorityReadConcern && replCoord->getReplicationMode() == repl::ReplicationCoordinator::Mode::modeReplSet) { // ReadConcern Majority is not supported in ProtocolVersion 0. |