summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsphanse99 <32846893+sphanse99@users.noreply.github.com>2022-03-29 20:01:42 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-29 21:32:20 +0000
commit8cf8aae5cb3ce6892ad1714043db6b66aafc9fbc (patch)
treeb6e7264e8f07307b4e1acd88c0ba63257ceb5525
parent99419b86ee823cf546a2843b9fb6f0b454f14774 (diff)
downloadmongo-8cf8aae5cb3ce6892ad1714043db6b66aafc9fbc.tar.gz
SERVER-64540 Add feature flag just for using txn API for updating document shard key value
-rw-r--r--src/mongo/s/commands/SConscript1
-rw-r--r--src/mongo/s/commands/cluster_find_and_modify_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_write_cmd.cpp5
-rw-r--r--src/mongo/s/commands/update_document_shard_key_using_transaction_api_feature_flag.idl41
4 files changed, 46 insertions, 5 deletions
diff --git a/src/mongo/s/commands/SConscript b/src/mongo/s/commands/SConscript
index adbc0a3c03c..aa268681c36 100644
--- a/src/mongo/s/commands/SConscript
+++ b/src/mongo/s/commands/SConscript
@@ -162,6 +162,7 @@ env.Library(
'cluster_write_cmd.cpp',
'document_shard_key_update_util.cpp',
'strategy.cpp',
+ 'update_document_shard_key_using_transaction_api_feature_flag.idl',
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/commands/core',
diff --git a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp
index 5931b4b1d73..2530c8b3772 100644
--- a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp
+++ b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/commands.h"
#include "mongo/db/commands/update_metrics.h"
#include "mongo/db/fle_crud.h"
-#include "mongo/db/internal_transactions_feature_flag_gen.h"
#include "mongo/db/ops/write_ops_gen.h"
#include "mongo/db/query/collation/collator_factory_interface.h"
#include "mongo/db/storage/duplicate_key_error_info.h"
@@ -57,6 +56,7 @@
#include "mongo/s/commands/cluster_explain.h"
#include "mongo/s/commands/document_shard_key_update_util.h"
#include "mongo/s/commands/strategy.h"
+#include "mongo/s/commands/update_document_shard_key_using_transaction_api_feature_flag_gen.h"
#include "mongo/s/grid.h"
#include "mongo/s/multi_statement_transaction_requests_sender.h"
#include "mongo/s/session_catalog_router.h"
@@ -541,7 +541,7 @@ private:
}
if (responseStatus.code() == ErrorCodes::WouldChangeOwningShard) {
- if (feature_flags::gFeatureFlagInternalTransactions.isEnabled(
+ if (feature_flags::gFeatureFlagUpdateDocumentShardKeyUsingTransactionApi.isEnabled(
serverGlobalParams.featureCompatibility)) {
auto parsedRequest = write_ops::FindAndModifyCommandRequest::parse(
IDLParserErrorContext("ClusterFindAndModify"), cmdObj);
diff --git a/src/mongo/s/commands/cluster_write_cmd.cpp b/src/mongo/s/commands/cluster_write_cmd.cpp
index e7fb4233e00..9deae5e4e91 100644
--- a/src/mongo/s/commands/cluster_write_cmd.cpp
+++ b/src/mongo/s/commands/cluster_write_cmd.cpp
@@ -35,7 +35,6 @@
#include "mongo/client/remote_command_targeter.h"
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/curop.h"
-#include "mongo/db/internal_transactions_feature_flag_gen.h"
#include "mongo/db/pipeline/lite_parsed_pipeline.h"
#include "mongo/db/stats/counters.h"
#include "mongo/db/storage/duplicate_key_error_info.h"
@@ -49,6 +48,7 @@
#include "mongo/s/cluster_write.h"
#include "mongo/s/commands/cluster_explain.h"
#include "mongo/s/commands/document_shard_key_update_util.h"
+#include "mongo/s/commands/update_document_shard_key_using_transaction_api_feature_flag_gen.h"
#include "mongo/s/grid.h"
#include "mongo/s/session_catalog_router.h"
#include "mongo/s/transaction_router.h"
@@ -288,8 +288,7 @@ bool handleWouldChangeOwningShardError(OperationContext* opCtx,
bool updatedShardKey = false;
boost::optional<BSONObj> upsertedId;
-
- if (feature_flags::gFeatureFlagInternalTransactions.isEnabled(
+ if (feature_flags::gFeatureFlagUpdateDocumentShardKeyUsingTransactionApi.isEnabled(
serverGlobalParams.featureCompatibility)) {
if (isRetryableWrite) {
if (MONGO_unlikely(hangAfterThrowWouldChangeOwningShardRetryableWrite.shouldFail())) {
diff --git a/src/mongo/s/commands/update_document_shard_key_using_transaction_api_feature_flag.idl b/src/mongo/s/commands/update_document_shard_key_using_transaction_api_feature_flag.idl
new file mode 100644
index 00000000000..8865c16559d
--- /dev/null
+++ b/src/mongo/s/commands/update_document_shard_key_using_transaction_api_feature_flag.idl
@@ -0,0 +1,41 @@
+# Copyright (C) 2022-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.
+#
+
+# Feature flag for enabling usage of the transaction api for update findAndModify and update commands that change a document's shard key.
+
+global:
+ cpp_namespace: "mongo::feature_flags"
+
+imports:
+ - "mongo/idl/basic_types.idl"
+
+feature_flags:
+ featureFlagUpdateDocumentShardKeyUsingTransactionApi:
+ description: Feature flag to enable usage of the transaction api for update findAndModify and update commands that change a document's shard key.
+ cpp_varname: gFeatureFlagUpdateDocumentShardKeyUsingTransactionApi
+ default: false