summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/core/views/views_all_commands.js1
-rw-r--r--src/mongo/db/catalog/SConscript14
-rw-r--r--src/mongo/db/catalog/commit_quorum.idl40
-rw-r--r--src/mongo/db/catalog/index_build_entry.idl19
-rw-r--r--src/mongo/db/commands/SConscript4
-rw-r--r--src/mongo/db/commands/set_index_commit_quorum.idl55
-rw-r--r--src/mongo/db/commands/set_index_commit_quorum_command.cpp101
-rw-r--r--src/mongo/db/commands/vote_commit_index_build_command.cpp (renamed from src/mongo/db/commands/vote_commit_index_builds_command.cpp)2
-rw-r--r--src/mongo/db/index_builds_coordinator.h4
-rw-r--r--src/mongo/db/index_builds_coordinator_mongod.cpp4
-rw-r--r--src/mongo/db/index_builds_coordinator_mongod.h4
-rw-r--r--src/mongo/embedded/index_builds_coordinator_embedded.cpp4
-rw-r--r--src/mongo/embedded/index_builds_coordinator_embedded.h4
13 files changed, 229 insertions, 27 deletions
diff --git a/jstests/core/views/views_all_commands.js b/jstests/core/views/views_all_commands.js
index baf28db424b..708b5b56889 100644
--- a/jstests/core/views/views_all_commands.js
+++ b/jstests/core/views/views_all_commands.js
@@ -464,6 +464,7 @@
saslContinue: {skip: isUnrelated},
saslStart: {skip: isUnrelated},
serverStatus: {command: {serverStatus: 1}, skip: isUnrelated},
+ setIndexCommitQuorum: {skip: isUnrelated},
setCommittedSnapshot: {skip: isAnInternalCommand},
setFeatureCompatibilityVersion: {skip: isUnrelated},
setFreeMonitoring: {skip: isUnrelated},
diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript
index 11e4ef09590..3c3d619a8e4 100644
--- a/src/mongo/db/catalog/SConscript
+++ b/src/mongo/db/catalog/SConscript
@@ -65,14 +65,24 @@ env.Library(
)
env.Library(
- target='index_build_entry_idl',
+ target='commit_quorum_idl',
source=[
- env.Idlc('index_build_entry.idl')[0],
+ env.Idlc('commit_quorum.idl')[0],
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/write_concern_options',
'$BUILD_DIR/mongo/idl/idl_parser',
+ ],
+)
+
+env.Library(
+ target='index_build_entry_idl',
+ source=[
+ env.Idlc('index_build_entry.idl')[0],
+ ],
+ LIBDEPS=[
+ 'commit_quorum_idl',
'$BUILD_DIR/mongo/util/net/network',
],
)
diff --git a/src/mongo/db/catalog/commit_quorum.idl b/src/mongo/db/catalog/commit_quorum.idl
new file mode 100644
index 00000000000..1c40369f1a1
--- /dev/null
+++ b/src/mongo/db/catalog/commit_quorum.idl
@@ -0,0 +1,40 @@
+# Copyright (C) 2018-present MongoDB, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Server Side Public License, version 1,
+# as published by MongoDB, Inc.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# Server Side Public License for more details.
+#
+# You should have received a copy of the Server Side Public License
+# along with this program. If not, see
+# <http://www.mongodb.com/licensing/server-side-public-license>.
+#
+# As a special exception, the copyright holders give permission to link the
+# code of portions of this program with the OpenSSL library under certain
+# conditions as described in each individual source file and distribute
+# linked combinations including the program with the OpenSSL library. You
+# must comply with the Server Side Public License in all respects for
+# all of the code used other than as permitted herein. If you modify file(s)
+# with this exception, you may extend this exception to your version of the
+# file(s), but you are not obligated to do so. If you do not wish to do so,
+# delete this exception statement from your version. If you delete this
+# exception statement from all source files in the program, then also delete
+# it in the license file.
+#
+
+global:
+ cpp_namespace: "mongo"
+ cpp_includes:
+ - "mongo/db/write_concern_options.h"
+
+types:
+ CommitQuorum:
+ bson_serialization_type: object
+ description: "CommitQuorum type that shadows the behaviour of WriteConcernOptions."
+ cpp_type: "mongo::WriteConcernOptions"
+ serializer: "mongo::WriteConcernOptions::toBSON"
+ deserializer: "mongo::WriteConcernOptions::deserializerForIDL"
diff --git a/src/mongo/db/catalog/index_build_entry.idl b/src/mongo/db/catalog/index_build_entry.idl
index dde8d2a23fc..9e54b3a1cb9 100644
--- a/src/mongo/db/catalog/index_build_entry.idl
+++ b/src/mongo/db/catalog/index_build_entry.idl
@@ -29,26 +29,18 @@
global:
cpp_namespace: "mongo"
cpp_includes:
- - "mongo/db/write_concern_options.h"
- "mongo/util/uuid.h"
imports:
+ - "mongo/db/catalog/commit_quorum.idl"
- "mongo/idl/basic_types.idl"
- "mongo/util/net/hostandport.idl"
-types:
- commitQuorum:
- bson_serialization_type: object
- description: "commitQuorum type that shadows the behaviour of WriteConcernOptions."
- cpp_type: "mongo::WriteConcernOptions"
- serializer: "mongo::WriteConcernOptions::toBSON"
- deserializer: "mongo::WriteConcernOptions::deserializerForIDL"
-
structs:
IndexBuildEntry:
description: "A document that tracks the progress of an index build across replica set
members."
- strict: true
+ strict: false
fields:
_id:
cpp_name: buildUUID
@@ -61,9 +53,10 @@ structs:
description: "Identifies the collection upon which the index is being built."
commitQuorum:
optional: false
- type: commitQuorum
- description: "commitQuorum has the same behaviour as writeConcern, indicating how
- many replica set members are needed to commit the index build."
+ type: CommitQuorum
+ description: "commitQuorum can be set to the same values as writeConcern.w and
+ indicates how many and/or which replica set members are needed for the
+ primary to commit the index build."
indexNames:
optional: false
type: array<string>
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index 9eb336c019a..5838657e7cf 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -309,13 +309,15 @@ env.Library(
"resize_oplog.cpp",
"restart_catalog_command.cpp",
"set_feature_compatibility_version_command.cpp",
+ "set_index_commit_quorum_command.cpp",
"shutdown_d.cpp",
"snapshot_management.cpp",
"top_command.cpp",
"touch.cpp",
"txn_cmds.cpp",
"user_management_commands.cpp",
- "vote_commit_index_builds_command.cpp",
+ "vote_commit_index_build_command.cpp",
+ env.Idlc('set_index_commit_quorum.idl')[0],
env.Idlc('vote_commit_index_build.idl')[0],
],
LIBDEPS=[
diff --git a/src/mongo/db/commands/set_index_commit_quorum.idl b/src/mongo/db/commands/set_index_commit_quorum.idl
new file mode 100644
index 00000000000..8925d73c904
--- /dev/null
+++ b/src/mongo/db/commands/set_index_commit_quorum.idl
@@ -0,0 +1,55 @@
+# Copyright (C) 2018-present MongoDB, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Server Side Public License, version 1,
+# as published by MongoDB, Inc.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# Server Side Public License for more details.
+#
+# You should have received a copy of the Server Side Public License
+# along with this program. If not, see
+# <http://www.mongodb.com/licensing/server-side-public-license>.
+#
+# As a special exception, the copyright holders give permission to link the
+# code of portions of this program with the OpenSSL library under certain
+# conditions as described in each individual source file and distribute
+# linked combinations including the program with the OpenSSL library. You
+# must comply with the Server Side Public License in all respects for
+# all of the code used other than as permitted herein. If you modify file(s)
+# with this exception, you may extend this exception to your version of the
+# file(s), but you are not obligated to do so. If you do not wish to do so,
+# delete this exception statement from your version. If you delete this
+# exception statement from all source files in the program, then also delete
+# it in the license file.
+#
+
+# setIndexCommitQuorum IDL File.
+
+global:
+ cpp_namespace: "mongo"
+ cpp_includes:
+ - "mongo/db/write_concern_options.h"
+
+imports:
+ - "mongo/db/catalog/commit_quorum.idl"
+ - "mongo/idl/basic_types.idl"
+
+commands:
+ setIndexCommitQuorum:
+ cpp_name: SetIndexCommitQuorum
+ description: "Resets the commitQuorum for an index build."
+ strict: false
+ namespace: concatenate_with_db
+ fields:
+ indexNames:
+ type: array<string>
+ description: "an array of all index names matching a single prior createIndexes
+ request."
+ commitQuorum:
+ type: CommitQuorum
+ description: "commitQuorum can be set to the same values as writeConcern.w and
+ indicates how many and/or which replica set members are needed for the
+ primary to commit the index build."
diff --git a/src/mongo/db/commands/set_index_commit_quorum_command.cpp b/src/mongo/db/commands/set_index_commit_quorum_command.cpp
new file mode 100644
index 00000000000..3ea933e43f4
--- /dev/null
+++ b/src/mongo/db/commands/set_index_commit_quorum_command.cpp
@@ -0,0 +1,101 @@
+/**
+ * Copyright (C) 2018-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kCommand
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/auth/authorization_session.h"
+#include "mongo/db/commands.h"
+#include "mongo/db/commands/set_index_commit_quorum_gen.h"
+#include "mongo/db/index_builds_coordinator.h"
+#include "mongo/db/write_concern_options.h"
+#include "mongo/util/log.h"
+
+namespace mongo {
+namespace {
+
+/**
+ * Resets the commitQuorum set on an index build identified by the list of index names that were
+ * previously specified in a createIndexes request.
+ *
+ * {
+ * setIndexCommitQuorum: coll,
+ * indexNames: ["x_1", "y_1", "xIndex", "someindexname"],
+ * commitQuorum: "majority" / 3 / {"replTagName": "replTagValue"},
+ * }
+ */
+class SetIndexCommitQuorumCommand final : public TypedCommand<SetIndexCommitQuorumCommand> {
+public:
+ using Request = SetIndexCommitQuorum;
+
+ std::string help() const override {
+ return "Resets the commitQuorum for an index build";
+ }
+
+ bool adminOnly() const override {
+ return false;
+ }
+
+ AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
+ return AllowedOnSecondary::kNever;
+ }
+
+ class Invocation final : public InvocationBase {
+ public:
+ using InvocationBase::InvocationBase;
+
+ void typedRun(OperationContext* opCtx) {
+ uassertStatusOK(IndexBuildsCoordinator::get(opCtx)->setCommitQuorum(
+ request().getNamespace(), request().getIndexNames(), request().getCommitQuorum()));
+ }
+
+ private:
+ NamespaceString ns() const override {
+ return request().getNamespace();
+ }
+
+ bool supportsWriteConcern() const override {
+ return true;
+ }
+
+ void doCheckAuthorization(OperationContext* opCtx) const override {
+ uassert(ErrorCodes::Unauthorized,
+ "Unauthorized",
+ AuthorizationSession::get(opCtx->getClient())
+ ->isAuthorizedForActionsOnResource(
+ ResourcePattern::forExactNamespace(request().getNamespace()),
+ ActionType::createIndex));
+ }
+ };
+
+} setCommitQuorumCmd;
+
+} // namespace
+} // namespace mongo
diff --git a/src/mongo/db/commands/vote_commit_index_builds_command.cpp b/src/mongo/db/commands/vote_commit_index_build_command.cpp
index e139ccbeb3d..8c4434981b9 100644
--- a/src/mongo/db/commands/vote_commit_index_builds_command.cpp
+++ b/src/mongo/db/commands/vote_commit_index_build_command.cpp
@@ -46,7 +46,7 @@ namespace {
* the provided index build UUID.
*
* {
- * voteCommitIndexBuilds: <index_build_uuid>,
+ * voteCommitIndexBuild: <index_build_uuid>,
* hostAndPort: "host:port",
* }
*/
diff --git a/src/mongo/db/index_builds_coordinator.h b/src/mongo/db/index_builds_coordinator.h
index e19bc7798ea..e436e7cbef9 100644
--- a/src/mongo/db/index_builds_coordinator.h
+++ b/src/mongo/db/index_builds_coordinator.h
@@ -192,8 +192,8 @@ public:
* the collection UUID.)
*/
virtual Status setCommitQuorum(const NamespaceString& nss,
- const std::vector<std::string>& indexNames,
- const BSONObj& newCommitQuorum) = 0;
+ const std::vector<StringData>& indexNames,
+ const WriteConcernOptions& newCommitQuorum) = 0;
/**
* TODO: This is not yet implemented.
diff --git a/src/mongo/db/index_builds_coordinator_mongod.cpp b/src/mongo/db/index_builds_coordinator_mongod.cpp
index 574bd9f0531..e2ec2403bd5 100644
--- a/src/mongo/db/index_builds_coordinator_mongod.cpp
+++ b/src/mongo/db/index_builds_coordinator_mongod.cpp
@@ -157,8 +157,8 @@ Status IndexBuildsCoordinatorMongod::voteCommitIndexBuild(const UUID& buildUUID,
}
Status IndexBuildsCoordinatorMongod::setCommitQuorum(const NamespaceString& nss,
- const std::vector<std::string>& indexNames,
- const BSONObj& newCommitQuorum) {
+ const std::vector<StringData>& indexNames,
+ const WriteConcernOptions& newCommitQuorum) {
// TODO: not yet implemented.
return Status::OK();
}
diff --git a/src/mongo/db/index_builds_coordinator_mongod.h b/src/mongo/db/index_builds_coordinator_mongod.h
index 2664d65e985..b4879f829bc 100644
--- a/src/mongo/db/index_builds_coordinator_mongod.h
+++ b/src/mongo/db/index_builds_coordinator_mongod.h
@@ -81,8 +81,8 @@ public:
Status voteCommitIndexBuild(const UUID& buildUUID, const HostAndPort& hostAndPort) override;
Status setCommitQuorum(const NamespaceString& nss,
- const std::vector<std::string>& indexNames,
- const BSONObj& newCommitQuorum) override;
+ const std::vector<StringData>& indexNames,
+ const WriteConcernOptions& newCommitQuorum) override;
private:
/**
diff --git a/src/mongo/embedded/index_builds_coordinator_embedded.cpp b/src/mongo/embedded/index_builds_coordinator_embedded.cpp
index d797d8f08d2..56b25453114 100644
--- a/src/mongo/embedded/index_builds_coordinator_embedded.cpp
+++ b/src/mongo/embedded/index_builds_coordinator_embedded.cpp
@@ -98,8 +98,8 @@ Status IndexBuildsCoordinatorEmbedded::voteCommitIndexBuild(const UUID& buildUUI
}
Status IndexBuildsCoordinatorEmbedded::setCommitQuorum(const NamespaceString& nss,
- const std::vector<std::string>& indexNames,
- const BSONObj& newCommitQuorum) {
+ const std::vector<StringData>& indexNames,
+ const WriteConcernOptions& newCommitQuorum) {
MONGO_UNREACHABLE;
}
diff --git a/src/mongo/embedded/index_builds_coordinator_embedded.h b/src/mongo/embedded/index_builds_coordinator_embedded.h
index 0689bea19d4..2e5e9678dad 100644
--- a/src/mongo/embedded/index_builds_coordinator_embedded.h
+++ b/src/mongo/embedded/index_builds_coordinator_embedded.h
@@ -69,8 +69,8 @@ public:
void signalChangeToInitialSyncMode() override;
Status voteCommitIndexBuild(const UUID& buildUUID, const HostAndPort& hostAndPort) override;
Status setCommitQuorum(const NamespaceString& nss,
- const std::vector<std::string>& indexNames,
- const BSONObj& newCommitQuorum) override;
+ const std::vector<StringData>& indexNames,
+ const WriteConcernOptions& newCommitQuorum) override;
private:
void _runIndexBuild(OperationContext* opCtx, const UUID& buildUUID) noexcept override;