From b2991cb000c5b6a606fca5f5896bca98fe87fa1c Mon Sep 17 00:00:00 2001 From: Jordi Serra Torrens Date: Fri, 17 Jun 2022 11:16:41 +0000 Subject: [PATCH] repro SERVER-67348 --- jstests/sharding/set_cluster_parameter.js | 5 +++++ .../config/set_cluster_parameter_coordinator.cpp | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/jstests/sharding/set_cluster_parameter.js b/jstests/sharding/set_cluster_parameter.js index 754245b02df..761323b5c23 100644 --- a/jstests/sharding/set_cluster_parameter.js +++ b/jstests/sharding/set_cluster_parameter.js @@ -159,6 +159,8 @@ const checkClusterParameters = failCommands: ["_shardsvrSetClusterParameter"] }); + let setClusterParamCoordinatorHangAfterFailureFp = configureFailPoint(st.configRS.getPrimary(), 'setClusterParamCoordinatorHangAfterFailure'); + let setClusterParameterThread = new Thread((mongosConnString, clusterParameter) => { let mongos = new Mongo(mongosConnString); assert.commandWorked(mongos.adminCommand({setClusterParameter: clusterParameter})); @@ -167,10 +169,13 @@ const checkClusterParameters = shardsvrSetClusterParameterFailPoint.wait(); + setClusterParamCoordinatorHangAfterFailureFp.wait(); + assert.commandFailedWithCode( st.s.adminCommand({addShard: newShard.getURL(), name: newShardName, maxTimeMS: 1000}), ErrorCodes.MaxTimeMSExpired); + setClusterParamCoordinatorHangAfterFailureFp.off(); shardsvrSetClusterParameterFailPoint.off(); setClusterParameterThread.join(); diff --git a/src/mongo/db/s/config/set_cluster_parameter_coordinator.cpp b/src/mongo/db/s/config/set_cluster_parameter_coordinator.cpp index 36543c7cbaa..51eab12dcc7 100644 --- a/src/mongo/db/s/config/set_cluster_parameter_coordinator.cpp +++ b/src/mongo/db/s/config/set_cluster_parameter_coordinator.cpp @@ -45,6 +45,7 @@ #include "mongo/logv2/log.h" #include "mongo/s/grid.h" #include "mongo/s/request_types/sharded_ddl_commands_gen.h" +#include "mongo/util/fail_point.h" #define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kSharding @@ -52,10 +53,12 @@ namespace mongo { namespace { +MONGO_FAIL_POINT_DEFINE(setClusterParamCoordinatorHangAfterFailure); + const WriteConcernOptions kMajorityWriteConcern{WriteConcernOptions::kMajority, WriteConcernOptions::SyncMode::UNSET, WriteConcernOptions::kNoTimeout}; -} +} // namespace bool SetClusterParameterCoordinator::hasSameOptions(const BSONObj& otherDocBSON) const { const auto otherDoc = StateDoc::parse( @@ -189,7 +192,8 @@ ExecutorFuture SetClusterParameterCoordinator::_runImpl( } }) .then(_executePhase( - Phase::kSetClusterParameter, [this, executor = executor, anchor = shared_from_this()] { + Phase::kSetClusterParameter, + [this, executor = executor, anchor = shared_from_this()] { auto opCtxHolder = cc().makeOperationContext(); auto* opCtx = opCtxHolder.get(); @@ -228,7 +232,13 @@ ExecutorFuture SetClusterParameterCoordinator::_runImpl( NamespaceString::kClusterParametersNamespace.toString(), _doc.getParameter(), kMajorityWriteConcern); - })); + })) + .onError([this](Status s) { + LOGV2(00000, "--XXXX-- SetClusterParameterCoordinator onError", "error"_attr = s); + setClusterParamCoordinatorHangAfterFailure.pauseWhileSet(); + LOGV2( + 00000, "--XXXX-- SetClusterParameterCoordinator onError - done", "error"_attr = s); + }); } } // namespace mongo -- 2.17.1