summaryrefslogtreecommitdiff
path: root/src/mongo/s/write_ops/batched_command_request.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/write_ops/batched_command_request.cpp')
-rw-r--r--src/mongo/s/write_ops/batched_command_request.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/mongo/s/write_ops/batched_command_request.cpp b/src/mongo/s/write_ops/batched_command_request.cpp
index 185857d6acc..107f1a49204 100644
--- a/src/mongo/s/write_ops/batched_command_request.cpp
+++ b/src/mongo/s/write_ops/batched_command_request.cpp
@@ -38,6 +38,8 @@
namespace mongo {
namespace {
+const auto kWriteConcern = "writeConcern"_sd;
+
template <class T>
BatchedCommandRequest constructBatchedCommandRequest(const OpMsgRequest& request) {
auto batchRequest = BatchedCommandRequest{T::parse(request)};
@@ -51,6 +53,11 @@ BatchedCommandRequest constructBatchedCommandRequest(const OpMsgRequest& request
batchRequest.setShardVersion(shardVersion);
}
+ auto writeConcernField = request.body[kWriteConcern];
+ if (!writeConcernField.eoo()) {
+ batchRequest.setWriteConcern(writeConcernField.Obj());
+ }
+
// The 'isTimeseriesNamespace' is an internal parameter used for communication between mongos
// and mongod.
auto isTimeseriesNamespace =
@@ -166,9 +173,19 @@ const boost::optional<BSONObj>& BatchedCommandRequest::getLet() const {
return _visit(Visitor{});
};
-const OptionalBool& BatchedCommandRequest::getBypassEmptyTsReplacement() const {
- return _visit([](auto&& op) -> decltype(auto) { return op.getBypassEmptyTsReplacement(); });
-};
+bool BatchedCommandRequest::isVerboseWC() const {
+ if (!hasWriteConcern()) {
+ return true;
+ }
+
+ BSONObj writeConcern = getWriteConcern();
+ BSONElement wElem = writeConcern["w"];
+ if (!wElem.isNumber() || wElem.Number() != 0) {
+ return true;
+ }
+
+ return false;
+}
const write_ops::WriteCommandRequestBase& BatchedCommandRequest::getWriteCommandRequestBase()
const {
@@ -189,6 +206,10 @@ void BatchedCommandRequest::serialize(BSONObjBuilder* builder) const {
if (_dbVersion) {
builder->append("databaseVersion", _dbVersion->toBSON());
}
+
+ if (_writeConcern) {
+ builder->append(kWriteConcern, *_writeConcern);
+ }
}
BSONObj BatchedCommandRequest::toBSON() const {