summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2018-08-02 15:23:19 -0400
committerHenrik Edin <henrik.edin@mongodb.com>2018-09-14 14:21:53 -0400
commitd1a7071f3ab06fc50a66db3d4ca8f929fc8ef1f0 (patch)
treecd0287a5e52db1e598f7c023a57dc37372fb2ae3 /src
parent7175fb8928cf48926caece2f7ded66dba3f47955 (diff)
downloadmongo-d1a7071f3ab06fc50a66db3d4ca8f929fc8ef1f0.tar.gz
SERVER-34577 Parse read and write concern for command invocation in embedded. Behave like a standalone mongod.
(cherry picked from commit 5de2e9361b92fbbc59625636eecbe6bd1f1a78c5)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.cpp12
-rw-r--r--src/mongo/embedded/service_entry_point_embedded.cpp38
2 files changed, 40 insertions, 10 deletions
diff --git a/src/mongo/embedded/replication_coordinator_embedded.cpp b/src/mongo/embedded/replication_coordinator_embedded.cpp
index 5ccff70e5dd..66ef5a00cec 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.cpp
+++ b/src/mongo/embedded/replication_coordinator_embedded.cpp
@@ -32,6 +32,7 @@
#include "mongo/embedded/replication_coordinator_embedded.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/repl/repl_set_config.h"
#include "mongo/embedded/not_implemented.h"
@@ -208,7 +209,16 @@ OpTime ReplicationCoordinatorEmbedded::getMyLastDurableOpTime() const {
}
Status ReplicationCoordinatorEmbedded::waitUntilOpTimeForRead(OperationContext*,
- const ReadConcernArgs&) {
+ const ReadConcernArgs& readConcern) {
+ // nothing to wait for
+ auto level = readConcern.getLevel();
+ if ((level == ReadConcernLevel::kLocalReadConcern ||
+ level == ReadConcernLevel::kAvailableReadConcern) &&
+ (!readConcern.getArgsAfterClusterTime() && !readConcern.getArgsOpTime() &&
+ !readConcern.getArgsAtClusterTime())) {
+ return Status::OK();
+ }
+
UASSERT_NOT_IMPLEMENTED;
}
diff --git a/src/mongo/embedded/service_entry_point_embedded.cpp b/src/mongo/embedded/service_entry_point_embedded.cpp
index 3efc2848b80..b1271e9814c 100644
--- a/src/mongo/embedded/service_entry_point_embedded.cpp
+++ b/src/mongo/embedded/service_entry_point_embedded.cpp
@@ -32,6 +32,7 @@
#include "mongo/embedded/service_entry_point_embedded.h"
+#include "mongo/db/read_concern.h"
#include "mongo/db/service_entry_point_common.h"
#include "mongo/embedded/not_implemented.h"
#include "mongo/embedded/periodic_runner_embedded.h"
@@ -44,18 +45,37 @@ public:
return false;
}
- void waitForReadConcern(OperationContext*,
- const CommandInvocation*,
- const OpMsgRequest&) const override {}
+ void waitForReadConcern(OperationContext* opCtx,
+ const CommandInvocation* invocation,
+ const OpMsgRequest& request) const override {
+ auto rcStatus = mongo::waitForReadConcern(
+ opCtx, repl::ReadConcernArgs::get(opCtx), invocation->allowsAfterClusterTime());
+ uassertStatusOK(rcStatus);
+ }
- void waitForWriteConcern(OperationContext*,
- const CommandInvocation*,
- const repl::OpTime&,
- BSONObjBuilder&) const override {}
+ void waitForWriteConcern(OperationContext* opCtx,
+ const CommandInvocation* invocation,
+ const repl::OpTime& lastOpBeforeRun,
+ BSONObjBuilder& commandResponseBuilder) const override {
+ WriteConcernResult res;
+ auto waitForWCStatus =
+ mongo::waitForWriteConcern(opCtx, lastOpBeforeRun, opCtx->getWriteConcern(), &res);
- void waitForLinearizableReadConcern(OperationContext*) const override {}
+ CommandHelpers::appendCommandWCStatus(commandResponseBuilder, waitForWCStatus, res);
+ }
- void uassertCommandDoesNotSpecifyWriteConcern(const BSONObj&) const override {}
+ void waitForLinearizableReadConcern(OperationContext* opCtx) const override {
+ if (repl::ReadConcernArgs::get(opCtx).getLevel() ==
+ repl::ReadConcernLevel::kLinearizableReadConcern) {
+ uassertStatusOK(mongo::waitForLinearizableReadConcern(opCtx));
+ }
+ }
+
+ void uassertCommandDoesNotSpecifyWriteConcern(const BSONObj& cmd) const override {
+ if (commandSpecifiesWriteConcern(cmd)) {
+ uasserted(ErrorCodes::InvalidOptions, "Command does not support writeConcern");
+ }
+ }
void attachCurOpErrInfo(OperationContext*, const BSONObj&) const override {}
};