Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ydb/core/protos/feature_flags.proto
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ message TFeatureFlags {
optional bool EnablePDiskHighHDDInFlight = 110 [default = false];
optional bool UseVDisksBalancing = 111 [default = false];
optional bool EnableViews = 112 [default = false];
optional bool EnableServerlessExclusiveDynamicNodes = 113 [default = false];
}
1 change: 1 addition & 0 deletions ydb/core/testlib/basics/feature_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class TTestFeatureFlagsHolder {
FEATURE_FLAG_SETTER(EnableTopicMessageMeta)
FEATURE_FLAG_SETTER(EnableUuidAsPrimaryKey)
FEATURE_FLAG_SETTER(EnableTablePgTypes)
FEATURE_FLAG_SETTER(EnableServerlessExclusiveDynamicNodes)

#undef FEATURE_FLAG_SETTER
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct TParamsDelta {

std::tuple<NKikimrScheme::EStatus, TString>
VerifyParams(TParamsDelta* delta, const TPathId pathId, const TSubDomainInfo::TPtr& current,
const NKikimrSubDomains::TSubDomainSettings& input) {
const NKikimrSubDomains::TSubDomainSettings& input, const bool isServerlessExclusiveDynamicNodesEnabled) {
auto paramError = [](const TStringBuf& msg) {
return std::make_tuple(NKikimrScheme::EStatus::StatusInvalidParameter,
TStringBuilder() << "Invalid ExtSubDomain request: " << msg
Expand Down Expand Up @@ -250,6 +250,12 @@ VerifyParams(TParamsDelta* delta, const TPathId pathId, const TSubDomainInfo::TP
// ServerlessComputeResourcesMode check
bool serverlessComputeResourcesModeChanged = false;
if (input.HasServerlessComputeResourcesMode()) {
if (!isServerlessExclusiveDynamicNodesEnabled) {
return std::make_tuple(NKikimrScheme::EStatus::StatusPreconditionFailed,
"Unsupported: feature flag EnableServerlessExclusiveDynamicNodes is off"
);
}

switch (input.GetServerlessComputeResourcesMode()) {
case EServerlessComputeResourcesMode::SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED:
return paramError("can not set ServerlessComputeResourcesMode to SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED");
Expand Down Expand Up @@ -283,10 +289,11 @@ VerifyParams(TParamsDelta* delta, const TPathId pathId, const TSubDomainInfo::TP
}

void VerifyParams(TProposeResponse* result, TParamsDelta* delta, const TPathId pathId,
const TSubDomainInfo::TPtr& current, const NKikimrSubDomains::TSubDomainSettings& input) {
const TSubDomainInfo::TPtr& current, const NKikimrSubDomains::TSubDomainSettings& input,
const bool isServerlessExclusiveDynamicNodesEnabled) {
// TProposeRespose should come in assuming positive outcome (status NKikimrScheme::StatusAccepted, no errors)
Y_ABORT_UNLESS(result->IsAccepted());
auto [status, reason] = VerifyParams(delta, pathId, current, input);
auto [status, reason] = VerifyParams(delta, pathId, current, input, isServerlessExclusiveDynamicNodesEnabled);
result->SetStatus(status, reason);
}

Expand Down Expand Up @@ -595,7 +602,7 @@ class TAlterExtSubDomainCreateHive: public TSubOperation {

// Check params and build change delta
TParamsDelta delta;
VerifyParams(result.Get(), &delta, basenameId, subdomainInfo, inputSettings);
VerifyParams(result.Get(), &delta, basenameId, subdomainInfo, inputSettings, context.SS->EnableServerlessExclusiveDynamicNodes);
if (!result->IsAccepted()) {
return result;
}
Expand Down Expand Up @@ -809,7 +816,7 @@ class TAlterExtSubDomain: public TSubOperation {
case TTxState::ConfigureParts:
return MakeHolder<NSubDomainState::TConfigureParts>(OperationId);
case TTxState::Propose:
return MakeHolder<NSubDomainState::TPropose>(OperationId, TTxState::SyncHive);
return MakeHolder<NSubDomainState::TPropose>(OperationId);
case TTxState::SyncHive:
return MakeHolder<TSyncHive>(OperationId);
case TTxState::Done:
Expand Down Expand Up @@ -847,7 +854,7 @@ class TAlterExtSubDomain: public TSubOperation {

// Check params and build change delta
TParamsDelta delta;
VerifyParams(result.Get(), &delta, basenameId, subdomainInfo, inputSettings);
VerifyParams(result.Get(), &delta, basenameId, subdomainInfo, inputSettings, context.SS->EnableServerlessExclusiveDynamicNodes);
if (!result->IsAccepted()) {
return result;
}
Expand Down Expand Up @@ -1089,7 +1096,7 @@ TVector<ISubOperation::TPtr> CreateCompatibleAlterExtSubDomain(TOperationId id,
// Check params and build change delta
TParamsDelta delta;
{
auto [status, reason] = VerifyParams(&delta, basenameId, subdomainInfo, inputSettings);
auto [status, reason] = VerifyParams(&delta, basenameId, subdomainInfo, inputSettings, context.SS->EnableServerlessExclusiveDynamicNodes);
if (status != NKikimrScheme::EStatus::StatusAccepted) {
return errorResult(status, reason);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ class TConfigureParts: public TSubOperationState {
class TPropose: public TSubOperationState {
private:
const TOperationId OperationId;
const TTxState::ETxState NextState;

TString DebugHint() const override {
return TStringBuilder()
Expand All @@ -280,9 +279,8 @@ class TPropose: public TSubOperationState {
}

public:
TPropose(TOperationId id, TTxState::ETxState nextState = TTxState::Done)
TPropose(TOperationId id)
: OperationId(id)
, NextState(nextState)
{
IgnoreMessages(DebugHint(), {
TEvHive::TEvCreateTabletReply::EventType,
Expand Down Expand Up @@ -348,8 +346,12 @@ class TPropose: public TSubOperationState {
context.SS->ClearDescribePathCaches(path);
context.OnComplete.PublishToSchemeBoard(OperationId, pathId);

context.SS->ChangeTxState(db, OperationId, NextState);

if (txState->NeedSyncHive) {
context.SS->ChangeTxState(db, OperationId, TTxState::SyncHive);
} else {
context.SS->ChangeTxState(db, OperationId, TTxState::Done);
}

LOG_DEBUG_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
"NSubDomainState::TPropose HandleReply TEvOperationPlan"
<< ", operationId " << OperationId
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4266,6 +4266,7 @@ void TSchemeShard::OnActivateExecutor(const TActorContext &ctx) {
EnablePQConfigTransactionsAtSchemeShard = appData->FeatureFlags.GetEnablePQConfigTransactionsAtSchemeShard();
EnableStatistics = appData->FeatureFlags.GetEnableStatistics();
EnableTablePgTypes = appData->FeatureFlags.GetEnableTablePgTypes();
EnableServerlessExclusiveDynamicNodes = appData->FeatureFlags.GetEnableServerlessExclusiveDynamicNodes();

ConfigureCompactionQueues(appData->CompactionConfig, ctx);
ConfigureStatsBatching(appData->SchemeShardConfig, ctx);
Expand Down Expand Up @@ -6755,6 +6756,7 @@ void TSchemeShard::ApplyConsoleConfigs(const NKikimrConfig::TFeatureFlags& featu
EnablePQConfigTransactionsAtSchemeShard = featureFlags.GetEnablePQConfigTransactionsAtSchemeShard();
EnableStatistics = featureFlags.GetEnableStatistics();
EnableTablePgTypes = featureFlags.GetEnableTablePgTypes();
EnableServerlessExclusiveDynamicNodes = featureFlags.GetEnableServerlessExclusiveDynamicNodes();
}

void TSchemeShard::ConfigureStatsBatching(const NKikimrConfig::TSchemeShardConfig& config, const TActorContext& ctx) {
Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/schemeshard/schemeshard_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class TSchemeShard
bool EnablePQConfigTransactionsAtSchemeShard = false;
bool EnableStatistics = false;
bool EnableTablePgTypes = false;
bool EnableServerlessExclusiveDynamicNodes = false;

TShardDeleter ShardDeleter;

Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/schemeshard/ut_helpers/test_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ NSchemeShardUT_Private::TTestEnv::TTestEnv(TTestActorRuntime& runtime, const TTe
app.SetEnableChangefeedDynamoDBStreamsFormat(opts.EnableChangefeedDynamoDBStreamsFormat_);
app.SetEnableChangefeedDebeziumJsonFormat(opts.EnableChangefeedDebeziumJsonFormat_);
app.SetEnableTablePgTypes(opts.EnableTablePgTypes_);
app.SetEnableServerlessExclusiveDynamicNodes(opts.EnableServerlessExclusiveDynamicNodes_);

app.ColumnShardConfig.SetDisabledOnSchemeShard(false);

Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/schemeshard/ut_helpers/test_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace NSchemeShardUT_Private {
OPTION(std::optional<bool>, EnableChangefeedDynamoDBStreamsFormat, std::nullopt);
OPTION(std::optional<bool>, EnableChangefeedDebeziumJsonFormat, std::nullopt);
OPTION(std::optional<bool>, EnableTablePgTypes, std::nullopt);
OPTION(std::optional<bool>, EnableServerlessExclusiveDynamicNodes, std::nullopt);

#undef OPTION
};
Expand Down
77 changes: 74 additions & 3 deletions ydb/core/tx/schemeshard/ut_serverless/ut_serverless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) {

Y_UNIT_TEST(TestServerlessComputeResourcesMode) {
TTestBasicRuntime runtime;
TTestEnv env(runtime);
TTestEnv env(runtime, TTestEnvOptions().EnableServerlessExclusiveDynamicNodes(true));
ui64 txId = 100;

TestCreateExtSubDomain(runtime, ++txId, "/MyRoot",
Expand Down Expand Up @@ -359,7 +359,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) {

Y_UNIT_TEST(TestServerlessComputeResourcesModeValidation) {
TTestBasicRuntime runtime;
TTestEnv env(runtime);
TTestEnv env(runtime, TTestEnvOptions().EnableServerlessExclusiveDynamicNodes(true));
ui64 txId = 100;

TestCreateExtSubDomain(runtime, ++txId, "/MyRoot",
Expand Down Expand Up @@ -431,9 +431,80 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) {
TestAlterExtSubDomain(runtime, ++txId, "/MyRoot",
R"(
ServerlessComputeResourcesMode: SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED
Name: "SharedDB"
Name: "ServerLess0"
)",
{{ TEvSchemeShard::EStatus::StatusInvalidParameter, "SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED" }}
);
}


Y_UNIT_TEST(TestServerlessComputeResourcesModeFeatureFlag) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().EnableServerlessExclusiveDynamicNodes(false));
ui64 txId = 100;

TestCreateExtSubDomain(runtime, ++txId, "/MyRoot",
R"(Name: "SharedDB")"
);
env.TestWaitNotification(runtime, txId);

TestAlterExtSubDomain(runtime, ++txId, "/MyRoot",
R"(
StoragePools {
Name: "pool-1"
Kind: "pool-kind-1"
}
StoragePools {
Name: "pool-2"
Kind: "pool-kind-2"
}
PlanResolution: 50
Coordinators: 1
Mediators: 1
TimeCastBucketsPerMediator: 2
ExternalSchemeShard: true
ExternalHive: true
Name: "SharedDB"
)"
);
env.TestWaitNotification(runtime, txId);

TString createData = Sprintf(
R"(
ResourcesDomainKey {
SchemeShard: %lu
PathId: 2
}
Name: "ServerLess0"
)",
TTestTxConfig::SchemeShard
);
TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", createData);
env.TestWaitNotification(runtime, txId);

TestAlterExtSubDomain(runtime, ++txId, "/MyRoot",
R"(
PlanResolution: 50
Coordinators: 1
Mediators: 1
TimeCastBucketsPerMediator: 2
ExternalSchemeShard: true
ExternalHive: false
StoragePools {
Name: "pool-1"
Kind: "pool-kind-1"
}
Name: "ServerLess0"
)"
);
env.TestWaitNotification(runtime, txId);

TestAlterExtSubDomain(runtime, ++txId, "/MyRoot",
R"(
ServerlessComputeResourcesMode: SERVERLESS_COMPUTE_RESOURCES_MODE_DEDICATED
Name: "ServerLess0"
)",
{{ TEvSchemeShard::EStatus::StatusPreconditionFailed, "Unsupported: feature flag EnableServerlessExclusiveDynamicNodes is off" }}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLessReboots) {

Y_UNIT_TEST(TestServerlessComputeResourcesModeWithReboots) {
TTestWithReboots t;
t.GetTestEnvOptions().EnableServerlessExclusiveDynamicNodes(true);

t.Run([&](TTestActorRuntime& runtime, bool& activeZone) {
ui64 sharedHive = 0;
ui64 tenantSchemeShard = 0;
Expand Down
3 changes: 2 additions & 1 deletion ydb/tests/functional/serverless/test_serverless.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
'GRPC_SERVER': LogLevels.DEBUG
},
enforce_user_token_requirement=True,
default_user_sid="user@builtin"
default_user_sid='user@builtin',
extra_feature_flags=['enable_serverless_exclusive_dynamic_nodes']
)


Expand Down