mirror of https://github.com/mongodb/mongo
SERVER-114004 Add command stub for _shardsvrReshardRecipientCriticalSectionStarted (#44064)
GitOrigin-RevId: be397396d296fc391ba279cc6ec769f576d6ebb1
This commit is contained in:
parent
cfcc2e4bd9
commit
11f2f90d6a
|
|
@ -736,6 +736,12 @@ const internalCommandsMap = {
|
|||
donorShards: [],
|
||||
},
|
||||
},
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: {
|
||||
testname: "_shardsvrReshardRecipientCriticalSectionStarted",
|
||||
command: {
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: UUID(),
|
||||
},
|
||||
},
|
||||
_shardsvrRefineCollectionShardKey: {
|
||||
testname: "_shardsvrRefineCollectionShardKey",
|
||||
command: {_shardsvrRefineCollectionShardKey: "test.x", newShardKey: {}},
|
||||
|
|
|
|||
|
|
@ -3513,6 +3513,23 @@ export const authCommandsLib = {
|
|||
{runOnDb: secondDbName, roles: {}},
|
||||
],
|
||||
},
|
||||
{
|
||||
testname: "_shardsvrReshardRecipientCriticalSectionStarted",
|
||||
command: {
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: UUID(),
|
||||
},
|
||||
skipSharded: true,
|
||||
testcases: [
|
||||
{
|
||||
runOnDb: adminDbName,
|
||||
roles: {__system: 1},
|
||||
privileges: [{resource: {cluster: true}, actions: ["internal"]}],
|
||||
expectFail: true,
|
||||
},
|
||||
{runOnDb: firstDbName, roles: {}},
|
||||
{runOnDb: secondDbName, roles: {}},
|
||||
],
|
||||
},
|
||||
{
|
||||
testname: "clusterCommitTransaction",
|
||||
command: {clusterCommitTransaction: 1},
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ let viewsCommandTests = {
|
|||
_shardsvrReshardingDonorStartChangeStreamsMonitor: {skip: isAnInternalCommand},
|
||||
_shardsvrReshardingOperationTime: {skip: isAnInternalCommand},
|
||||
_shardsvrReshardRecipientClone: {skip: isAnInternalCommand},
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: {skip: isAnInternalCommand},
|
||||
_shardsvrSetAllowMigrations: {skip: isAnInternalCommand},
|
||||
_shardsvrResolveView: {skip: isAnInternalCommand},
|
||||
_shardsvrRunSearchIndexCommand: {skip: isAnInternalCommand},
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ const wcCommandsTests = {
|
|||
_shardsvrReshardingDonorStartChangeStreamsMonitor: {skip: "internal command"},
|
||||
_shardsvrReshardingOperationTime: {skip: "internal command"},
|
||||
_shardsvrReshardRecipientClone: {skip: "internal command"},
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: {skip: "internal command"},
|
||||
_shardsvrResolveView: {skip: "internal command"},
|
||||
_shardsvrRunSearchIndexCommand: {skip: "internal command"},
|
||||
_shardsvrSetAllowMigrations: {skip: "internal command"},
|
||||
|
|
@ -3405,6 +3406,7 @@ const wcTimeseriesViewsCommandsTests = {
|
|||
_shardsvrReshardingDonorStartChangeStreamsMonitor: {skip: "internal command"},
|
||||
_shardsvrReshardingOperationTime: {skip: "internal command"},
|
||||
_shardsvrReshardRecipientClone: {skip: "internal command"},
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: {skip: "internal command"},
|
||||
_shardsvrResolveView: {skip: "internal command"},
|
||||
_shardsvrRunSearchIndexCommand: {skip: "internal command"},
|
||||
_shardsvrSetAllowMigrations: {skip: "internal command"},
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ const allCommands = {
|
|||
_shardsvrReshardingDonorStartChangeStreamsMonitor: {skip: isAnInternalCommand},
|
||||
_shardsvrReshardingOperationTime: {skip: isAnInternalCommand},
|
||||
_shardsvrReshardRecipientClone: {skip: isAnInternalCommand},
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: {skip: isAnInternalCommand},
|
||||
_shardsvrRefineCollectionShardKey: {skip: isAnInternalCommand},
|
||||
_shardsvrSetAllowMigrations: {skip: isAnInternalCommand},
|
||||
_shardsvrSetClusterParameter: {skip: isAnInternalCommand},
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ const allCommands = {
|
|||
_shardsvrReshardCollection: {skip: isPrimaryOnly},
|
||||
_shardsvrReshardingOperationTime: {skip: isPrimaryOnly},
|
||||
_shardsvrReshardRecipientClone: {skip: isPrimaryOnly},
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: {skip: isPrimaryOnly},
|
||||
_shardsvrRefineCollectionShardKey: {skip: isPrimaryOnly},
|
||||
_shardsvrSetAllowMigrations: {skip: isPrimaryOnly},
|
||||
_shardsvrSetClusterParameter: {skip: isAnInternalCommand},
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ const allCommands = {
|
|||
_shardsvrReshardCollection: {skip: isAnInternalCommand},
|
||||
_shardsvrReshardingOperationTime: {skip: isAnInternalCommand},
|
||||
_shardsvrReshardRecipientClone: {skip: isAnInternalCommand},
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: {skip: isAnInternalCommand},
|
||||
_shardsvrRefineCollectionShardKey: {skip: isAnInternalCommand},
|
||||
_shardsvrSetAllowMigrations: {skip: isAnInternalCommand},
|
||||
_shardsvrSetClusterParameter: {skip: isAnInternalCommand},
|
||||
|
|
|
|||
|
|
@ -1019,6 +1019,21 @@ const allTestCases = {
|
|||
_shardsvrRenameIndexMetadata: {skip: "TODO"},
|
||||
_shardsvrReshardCollection: {skip: "TODO"},
|
||||
_shardsvrReshardRecipientClone: {skip: "TODO"},
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: {
|
||||
run: {
|
||||
sendsDbVersion: false,
|
||||
runsAgainstAdminDb: true,
|
||||
command: function (dbName, collName) {
|
||||
return {
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: UUID(),
|
||||
};
|
||||
},
|
||||
// When the resharding recipient state machine does not exist, we throw
|
||||
// NotWritablePrimary under the assumption that the request was delayed and the
|
||||
// node is no longer the primary.
|
||||
expectedFailureCode: ErrorCodes.NotWritablePrimary,
|
||||
},
|
||||
},
|
||||
_shardsvrReshardingDonorFetchFinalCollectionStats: {skip: "TODO"},
|
||||
_shardsvrReshardingDonorStartChangeStreamsMonitor: {skip: "TODO"},
|
||||
_shardsvrReshardingOperationTime: {skip: "TODO"},
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ export const commandsAddedToMongodSinceLastLTS = [
|
|||
"_shardsvrRenameIndexMetadata",
|
||||
"getTrafficRecordingStatus",
|
||||
"_shardsvrReshardRecipientClone",
|
||||
"_shardsvrReshardRecipientCriticalSectionStarted",
|
||||
"_shardsvrResolveView",
|
||||
"_configsvrStartShardDraining",
|
||||
"_shardsvrDropIndexesParticipant",
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ let testCases = {
|
|||
_shardsvrReshardingDonorStartChangeStreamsMonitor: {skip: "internal command"},
|
||||
_shardsvrReshardingOperationTime: {skip: "internal command"},
|
||||
_shardsvrReshardRecipientClone: {skip: "internal command"},
|
||||
_shardsvrReshardRecipientCriticalSectionStarted: {skip: "internal command"},
|
||||
_shardsvrResolveView: {skip: "internal command"},
|
||||
_shardsvrRunSearchIndexCommand: {skip: "internal command"},
|
||||
_shardsvrSetAllowMigrations: {skip: "internal command"},
|
||||
|
|
|
|||
|
|
@ -716,6 +716,7 @@ mongo_cc_library(
|
|||
"shardsvr_get_stats_for_balancing_command.cpp",
|
||||
"shardsvr_move_range_command.cpp",
|
||||
"shardsvr_reshard_recipient_clone_cmd.cpp",
|
||||
"shardsvr_reshard_recipient_critical_section_started_cmd.cpp",
|
||||
"shardsvr_resharding_donor_fetch_final_collection_stats_command.cpp",
|
||||
"shardsvr_resharding_donor_start_change_streams_monitor_command.cpp",
|
||||
"shardsvr_resharding_operation_time_command.cpp",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,151 @@
|
|||
/**
|
||||
* Copyright (C) 2025-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.
|
||||
*/
|
||||
|
||||
|
||||
#include "mongo/base/error_codes.h"
|
||||
#include "mongo/bson/bsonmisc.h"
|
||||
#include "mongo/db/auth/action_type.h"
|
||||
#include "mongo/db/auth/authorization_session.h"
|
||||
#include "mongo/db/auth/resource_pattern.h"
|
||||
#include "mongo/db/commands.h"
|
||||
#include "mongo/db/database_name.h"
|
||||
#include "mongo/db/namespace_string.h"
|
||||
#include "mongo/db/operation_context.h"
|
||||
#include "mongo/db/s/resharding/resharding_donor_recipient_common.h"
|
||||
#include "mongo/db/s/resharding/resharding_recipient_service.h"
|
||||
#include "mongo/db/s/resharding/resharding_util.h"
|
||||
#include "mongo/db/server_options.h"
|
||||
#include "mongo/db/service_context.h"
|
||||
#include "mongo/db/topology/cluster_role.h"
|
||||
#include "mongo/logv2/log.h"
|
||||
#include "mongo/logv2/log_attr.h"
|
||||
#include "mongo/logv2/log_component.h"
|
||||
#include "mongo/rpc/op_msg.h"
|
||||
#include "mongo/s/request_types/reshard_collection_gen.h"
|
||||
#include "mongo/s/resharding/common_types_gen.h"
|
||||
#include "mongo/util/assert_util.h"
|
||||
#include "mongo/util/future.h"
|
||||
#include "mongo/util/uuid.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/optional/optional.hpp>
|
||||
|
||||
#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kCommand
|
||||
|
||||
namespace mongo {
|
||||
namespace {
|
||||
|
||||
class ShardsvrReshardRecipientCriticalSectionStartedCommand final
|
||||
: public TypedCommand<ShardsvrReshardRecipientCriticalSectionStartedCommand> {
|
||||
public:
|
||||
using Request = ShardsvrReshardRecipientCriticalSectionStarted;
|
||||
|
||||
class Invocation final : public InvocationBase {
|
||||
public:
|
||||
using InvocationBase::InvocationBase;
|
||||
|
||||
void typedRun(OperationContext* opCtx) {
|
||||
opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE();
|
||||
|
||||
uassert(
|
||||
ErrorCodes::IllegalOperation,
|
||||
"_shardsvrReshardRecipientCriticalSectionStarted can only be run on shard servers",
|
||||
serverGlobalParams.clusterRole.has(ClusterRole::ShardServer));
|
||||
|
||||
if (auto machine = resharding::tryGetReshardingStateMachineAndThrowIfShuttingDown<
|
||||
ReshardingRecipientService,
|
||||
ReshardingRecipientService::RecipientStateMachine,
|
||||
ReshardingRecipientDocument>(opCtx, uuid())) {
|
||||
|
||||
LOGV2(11400401,
|
||||
"Resharding recipient start executing "
|
||||
"_shardsvrRecipientCriticalSectionStarted command.",
|
||||
"reshardingUUID"_attr = uuid());
|
||||
|
||||
LOGV2(11400402,
|
||||
"Resharding recipient finished executing "
|
||||
"_shardsvrRecipientCriticalSectionStarted command.",
|
||||
"reshardingUUID"_attr = uuid());
|
||||
} else {
|
||||
// If state machine does not exist, either this message was delayed and the
|
||||
// resharding operation is done, or this node is no longer a primary.
|
||||
uasserted(ErrorCodes::NotWritablePrimary,
|
||||
"Internal Error: No matching resharding operation.");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
UUID uuid() const {
|
||||
return request().getCommandParameter();
|
||||
}
|
||||
|
||||
NamespaceString ns() const override {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool supportsWriteConcern() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
void doCheckAuthorization(OperationContext* opCtx) const override {
|
||||
uassert(ErrorCodes::Unauthorized,
|
||||
"Unauthorized",
|
||||
AuthorizationSession::get(opCtx->getClient())
|
||||
->isAuthorizedForActionsOnResource(
|
||||
ResourcePattern::forClusterResource(request().getDbName().tenantId()),
|
||||
ActionType::internal));
|
||||
}
|
||||
};
|
||||
|
||||
bool skipApiVersionCheck() const override {
|
||||
// Internal command (server to server).
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string help() const override {
|
||||
return "Internal command run by coordinator against recipients to notify them that the "
|
||||
"critical section has started. Do not call directly.";
|
||||
}
|
||||
|
||||
bool adminOnly() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
|
||||
return AllowedOnSecondary::kNever;
|
||||
}
|
||||
};
|
||||
MONGO_REGISTER_COMMAND(ShardsvrReshardRecipientCriticalSectionStartedCommand).forShard();
|
||||
|
||||
} // namespace
|
||||
} // namespace mongo
|
||||
|
|
@ -114,8 +114,8 @@ commands:
|
|||
demoMode:
|
||||
type: optionalBool
|
||||
description: >-
|
||||
"When set to true, overrides reshardingMinimumOperationDurationMillis
|
||||
and reshardingDelayBeforeRemainingOperationTimeQueryMillis values to 0
|
||||
"When set to true, overrides reshardingMinimumOperationDurationMillis
|
||||
and reshardingDelayBeforeRemainingOperationTimeQueryMillis values to 0
|
||||
for quick demo of reshardCollection operation"
|
||||
|
||||
_configsvrReshardCollection:
|
||||
|
|
@ -194,8 +194,8 @@ commands:
|
|||
demoMode:
|
||||
type: optionalBool
|
||||
description: >-
|
||||
"When set to true, overrides reshardingMinimumOperationDurationMillis
|
||||
and reshardingDelayBeforeRemainingOperationTimeQueryMillis values to 0
|
||||
"When set to true, overrides reshardingMinimumOperationDurationMillis
|
||||
and reshardingDelayBeforeRemainingOperationTimeQueryMillis values to 0
|
||||
for quick demo of reshardCollection operation"
|
||||
|
||||
rewriteCollection:
|
||||
|
|
@ -225,8 +225,8 @@ commands:
|
|||
demoMode:
|
||||
type: optionalBool
|
||||
description: >-
|
||||
"When set to true, overrides reshardingMinimumOperationDurationMillis
|
||||
and reshardingDelayBeforeRemainingOperationTimeQueryMillis values to 0
|
||||
"When set to true, overrides reshardingMinimumOperationDurationMillis
|
||||
and reshardingDelayBeforeRemainingOperationTimeQueryMillis values to 0
|
||||
for quick demo of reshardCollection operation"
|
||||
|
||||
moveCollection:
|
||||
|
|
@ -337,3 +337,15 @@ commands:
|
|||
approxCopySize:
|
||||
type: ReshardingApproxCopySize
|
||||
description: "Not meant to be used directly. Only use internal fields."
|
||||
|
||||
_shardsvrReshardRecipientCriticalSectionStarted:
|
||||
description:
|
||||
"The internal command run by coordinator against recipients to notify them that the
|
||||
critical section has started."
|
||||
command_name: _shardsvrReshardRecipientCriticalSectionStarted
|
||||
cpp_name: ShardsvrReshardRecipientCriticalSectionStarted
|
||||
type: uuid
|
||||
strict: false
|
||||
namespace: type
|
||||
reply_type: OkReply
|
||||
api_version: ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue