summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2018-08-09 10:09:35 -0400
committerEsha Maharishi <esha.maharishi@mongodb.com>2018-08-09 15:04:24 -0400
commit0faa26ed8b17295b071edb9c4debadada899aeb2 (patch)
tree4f72dea3d4fefbcab42082025aedc7438485b5e4
parent2c752e43b73692c70157226e1e62ae16fb2491ec (diff)
downloadmongo-0faa26ed8b17295b071edb9c4debadada899aeb2.tar.gz
SERVER-36297 Add stubs for the transaction two-phase commit voting commands
-rw-r--r--jstests/core/views/views_all_commands.js2
-rw-r--r--src/mongo/db/s/SConscript2
-rw-r--r--src/mongo/db/s/txn_two_phase_commit_cmds.cpp110
-rw-r--r--src/mongo/db/s/txn_two_phase_commit_cmds.idl41
4 files changed, 155 insertions, 0 deletions
diff --git a/jstests/core/views/views_all_commands.js b/jstests/core/views/views_all_commands.js
index 184d99a5462..bd707811ce4 100644
--- a/jstests/core/views/views_all_commands.js
+++ b/jstests/core/views/views_all_commands.js
@@ -539,6 +539,8 @@
usersInfo: {skip: isUnrelated},
validate: {command: {validate: "view"}, expectFailure: true},
waitForOngoingChunkSplits: {skip: isUnrelated},
+ voteCommitTransaction: {skip: isUnrelated},
+ voteAbortTransaction: {skip: isUnrelated},
whatsmyuri: {skip: isUnrelated}
};
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index b9ff8d16d97..b81dee88169 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -291,6 +291,7 @@ env.Library(
'config/configsvr_split_chunk_command.cpp',
'config/configsvr_update_zone_key_range_command.cpp',
'coordinate_commit_transaction_command.cpp',
+ 'txn_two_phase_commit_cmds.cpp',
'flush_database_cache_updates_command.cpp',
'flush_routing_table_cache_updates_command.cpp',
'get_database_version_command.cpp',
@@ -308,6 +309,7 @@ env.Library(
'split_vector_command.cpp',
'unset_sharding_command.cpp',
'wait_for_ongoing_chunk_splits_command.cpp',
+ env.Idlc("txn_two_phase_commit_cmds.idl")[0],
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/bson/dotted_path_support',
diff --git a/src/mongo/db/s/txn_two_phase_commit_cmds.cpp b/src/mongo/db/s/txn_two_phase_commit_cmds.cpp
new file mode 100644
index 00000000000..c7222d73f83
--- /dev/null
+++ b/src/mongo/db/s/txn_two_phase_commit_cmds.cpp
@@ -0,0 +1,110 @@
+/**
+ * Copyright (C) 2018 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * 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 GNU Affero General 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::kSharding
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/commands.h"
+#include "mongo/db/s/txn_two_phase_commit_cmds_gen.h"
+
+namespace mongo {
+namespace {
+
+class VoteCommitTransactionCmd : public TypedCommand<VoteCommitTransactionCmd> {
+public:
+ using Request = VoteCommitTransaction;
+ class Invocation final : public InvocationBase {
+ public:
+ using InvocationBase::InvocationBase;
+
+ void typedRun(OperationContext* opCtx) {}
+
+ private:
+ bool supportsWriteConcern() const override {
+ return false;
+ }
+
+ NamespaceString ns() const override {
+ return NamespaceString(request().getDbName(), "");
+ }
+
+ void doCheckAuthorization(OperationContext* opCtx) const override {}
+ };
+
+ virtual bool adminOnly() const {
+ return true;
+ }
+
+ std::string help() const override {
+ return "Votes to commit a transaction; sent by a transaction participant to the "
+ "transaction commit coordinator for a cross-shard transaction";
+ }
+
+ AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
+ return AllowedOnSecondary::kNever;
+ }
+} voteCommitTransactionCmd;
+
+class VoteAbortTransactionCmd : public TypedCommand<VoteAbortTransactionCmd> {
+public:
+ using Request = VoteAbortTransaction;
+ class Invocation final : public InvocationBase {
+ public:
+ using InvocationBase::InvocationBase;
+
+ void typedRun(OperationContext* opCtx) {}
+
+ private:
+ bool supportsWriteConcern() const override {
+ return false;
+ }
+
+ NamespaceString ns() const override {
+ return NamespaceString(request().getDbName(), "");
+ }
+
+ void doCheckAuthorization(OperationContext* opCtx) const override {}
+ };
+
+ virtual bool adminOnly() const {
+ return true;
+ }
+
+ std::string help() const override {
+ return "Votes to abort a transaction; sent by a transaction participant to the transaction "
+ "commit coordinator for a cross-shard transaction";
+ }
+
+ AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
+ return AllowedOnSecondary::kNever;
+ }
+} voteAbortTransactionCmd;
+
+} // namespace
+} // namespace mongo
diff --git a/src/mongo/db/s/txn_two_phase_commit_cmds.idl b/src/mongo/db/s/txn_two_phase_commit_cmds.idl
new file mode 100644
index 00000000000..92a2d557546
--- /dev/null
+++ b/src/mongo/db/s/txn_two_phase_commit_cmds.idl
@@ -0,0 +1,41 @@
+# Copyright (C) 2018 MongoDB Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License, version 3,
+# as published by the Free Software Foundation.
+#
+# 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
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+global:
+ cpp_namespace: "mongo"
+
+imports:
+ - "mongo/idl/basic_types.idl"
+ - "mongo/s/sharding_types.idl"
+
+commands:
+ voteCommitTransaction:
+ description: "voteCommitTransaction Command"
+ namespace: ignored
+ fields:
+ shardId:
+ description: "The shard name of the sender"
+ type: shard_id
+ prepareTimestamp:
+ description: "Timestamp at which the sender prepared the transaction"
+ optional: true
+ type: timestamp
+
+ voteAbortTransaction:
+ description: "voteAbortTransaction Command"
+ namespace: ignored
+ fields:
+ shardId:
+ description: "The shard name of the sender"
+ type: shard_id