Skip to content

Commit de10e83

Browse files
authored
Add feature flag for exclusive dynamic nodes KIKIMR-20562 (#748)
Add feature flag for exclusive dynamic nodes KIKIMR-20562
1 parent 33744f6 commit de10e83

File tree

11 files changed

+106
-16
lines changed

11 files changed

+106
-16
lines changed

ydb/core/protos/feature_flags.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,5 @@ message TFeatureFlags {
125125
optional bool EnablePDiskHighHDDInFlight = 110 [default = false];
126126
optional bool UseVDisksBalancing = 111 [default = false];
127127
optional bool EnableViews = 112 [default = false];
128+
optional bool EnableServerlessExclusiveDynamicNodes = 113 [default = false];
128129
}

ydb/core/testlib/basics/feature_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class TTestFeatureFlagsHolder {
5555
FEATURE_FLAG_SETTER(EnableTopicMessageMeta)
5656
FEATURE_FLAG_SETTER(EnableUuidAsPrimaryKey)
5757
FEATURE_FLAG_SETTER(EnableTablePgTypes)
58+
FEATURE_FLAG_SETTER(EnableServerlessExclusiveDynamicNodes)
5859

5960
#undef FEATURE_FLAG_SETTER
6061
};

ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct TParamsDelta {
4545

4646
std::tuple<NKikimrScheme::EStatus, TString>
4747
VerifyParams(TParamsDelta* delta, const TPathId pathId, const TSubDomainInfo::TPtr& current,
48-
const NKikimrSubDomains::TSubDomainSettings& input) {
48+
const NKikimrSubDomains::TSubDomainSettings& input, const bool isServerlessExclusiveDynamicNodesEnabled) {
4949
auto paramError = [](const TStringBuf& msg) {
5050
return std::make_tuple(NKikimrScheme::EStatus::StatusInvalidParameter,
5151
TStringBuilder() << "Invalid ExtSubDomain request: " << msg
@@ -266,6 +266,12 @@ VerifyParams(TParamsDelta* delta, const TPathId pathId, const TSubDomainInfo::TP
266266
// ServerlessComputeResourcesMode check
267267
bool serverlessComputeResourcesModeChanged = false;
268268
if (input.HasServerlessComputeResourcesMode()) {
269+
if (!isServerlessExclusiveDynamicNodesEnabled) {
270+
return std::make_tuple(NKikimrScheme::EStatus::StatusPreconditionFailed,
271+
"Unsupported: feature flag EnableServerlessExclusiveDynamicNodes is off"
272+
);
273+
}
274+
269275
switch (input.GetServerlessComputeResourcesMode()) {
270276
case EServerlessComputeResourcesMode::SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED:
271277
return paramError("can not set ServerlessComputeResourcesMode to SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED");
@@ -300,10 +306,11 @@ VerifyParams(TParamsDelta* delta, const TPathId pathId, const TSubDomainInfo::TP
300306
}
301307

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

@@ -612,7 +619,7 @@ class TAlterExtSubDomainCreateHive: public TSubOperation {
612619

613620
// Check params and build change delta
614621
TParamsDelta delta;
615-
VerifyParams(result.Get(), &delta, basenameId, subdomainInfo, inputSettings);
622+
VerifyParams(result.Get(), &delta, basenameId, subdomainInfo, inputSettings, context.SS->EnableServerlessExclusiveDynamicNodes);
616623
if (!result->IsAccepted()) {
617624
return result;
618625
}
@@ -826,7 +833,7 @@ class TAlterExtSubDomain: public TSubOperation {
826833
case TTxState::ConfigureParts:
827834
return MakeHolder<NSubDomainState::TConfigureParts>(OperationId);
828835
case TTxState::Propose:
829-
return MakeHolder<NSubDomainState::TPropose>(OperationId, TTxState::SyncHive);
836+
return MakeHolder<NSubDomainState::TPropose>(OperationId);
830837
case TTxState::SyncHive:
831838
return MakeHolder<TSyncHive>(OperationId);
832839
case TTxState::Done:
@@ -864,7 +871,7 @@ class TAlterExtSubDomain: public TSubOperation {
864871

865872
// Check params and build change delta
866873
TParamsDelta delta;
867-
VerifyParams(result.Get(), &delta, basenameId, subdomainInfo, inputSettings);
874+
VerifyParams(result.Get(), &delta, basenameId, subdomainInfo, inputSettings, context.SS->EnableServerlessExclusiveDynamicNodes);
868875
if (!result->IsAccepted()) {
869876
return result;
870877
}
@@ -1110,7 +1117,7 @@ TVector<ISubOperation::TPtr> CreateCompatibleAlterExtSubDomain(TOperationId id,
11101117
// Check params and build change delta
11111118
TParamsDelta delta;
11121119
{
1113-
auto [status, reason] = VerifyParams(&delta, basenameId, subdomainInfo, inputSettings);
1120+
auto [status, reason] = VerifyParams(&delta, basenameId, subdomainInfo, inputSettings, context.SS->EnableServerlessExclusiveDynamicNodes);
11141121
if (status != NKikimrScheme::EStatus::StatusAccepted) {
11151122
return errorResult(status, reason);
11161123
}

ydb/core/tx/schemeshard/schemeshard__operation_common_subdomain.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ class TConfigureParts: public TSubOperationState {
281281
class TPropose: public TSubOperationState {
282282
private:
283283
const TOperationId OperationId;
284-
const TTxState::ETxState NextState;
285284

286285
TString DebugHint() const override {
287286
return TStringBuilder()
@@ -290,9 +289,8 @@ class TPropose: public TSubOperationState {
290289
}
291290

292291
public:
293-
TPropose(TOperationId id, TTxState::ETxState nextState = TTxState::Done)
292+
TPropose(TOperationId id)
294293
: OperationId(id)
295-
, NextState(nextState)
296294
{
297295
IgnoreMessages(DebugHint(), {
298296
TEvHive::TEvCreateTabletReply::EventType,
@@ -358,8 +356,12 @@ class TPropose: public TSubOperationState {
358356
context.SS->ClearDescribePathCaches(path);
359357
context.OnComplete.PublishToSchemeBoard(OperationId, pathId);
360358

361-
context.SS->ChangeTxState(db, OperationId, NextState);
362-
359+
if (txState->NeedSyncHive) {
360+
context.SS->ChangeTxState(db, OperationId, TTxState::SyncHive);
361+
} else {
362+
context.SS->ChangeTxState(db, OperationId, TTxState::Done);
363+
}
364+
363365
LOG_DEBUG_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
364366
"NSubDomainState::TPropose HandleReply TEvOperationPlan"
365367
<< ", operationId " << OperationId

ydb/core/tx/schemeshard/schemeshard_impl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4270,6 +4270,7 @@ void TSchemeShard::OnActivateExecutor(const TActorContext &ctx) {
42704270
EnablePQConfigTransactionsAtSchemeShard = appData->FeatureFlags.GetEnablePQConfigTransactionsAtSchemeShard();
42714271
EnableStatistics = appData->FeatureFlags.GetEnableStatistics();
42724272
EnableTablePgTypes = appData->FeatureFlags.GetEnableTablePgTypes();
4273+
EnableServerlessExclusiveDynamicNodes = appData->FeatureFlags.GetEnableServerlessExclusiveDynamicNodes();
42734274

42744275
ConfigureCompactionQueues(appData->CompactionConfig, ctx);
42754276
ConfigureStatsBatching(appData->SchemeShardConfig, ctx);
@@ -6746,6 +6747,7 @@ void TSchemeShard::ApplyConsoleConfigs(const NKikimrConfig::TFeatureFlags& featu
67466747
EnablePQConfigTransactionsAtSchemeShard = featureFlags.GetEnablePQConfigTransactionsAtSchemeShard();
67476748
EnableStatistics = featureFlags.GetEnableStatistics();
67486749
EnableTablePgTypes = featureFlags.GetEnableTablePgTypes();
6750+
EnableServerlessExclusiveDynamicNodes = featureFlags.GetEnableServerlessExclusiveDynamicNodes();
67496751
}
67506752

67516753
void TSchemeShard::ConfigureStatsBatching(const NKikimrConfig::TSchemeShardConfig& config, const TActorContext& ctx) {

ydb/core/tx/schemeshard/schemeshard_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ class TSchemeShard
270270
bool EnablePQConfigTransactionsAtSchemeShard = false;
271271
bool EnableStatistics = false;
272272
bool EnableTablePgTypes = false;
273+
bool EnableServerlessExclusiveDynamicNodes = false;
273274

274275
TShardDeleter ShardDeleter;
275276

ydb/core/tx/schemeshard/ut_helpers/test_env.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ NSchemeShardUT_Private::TTestEnv::TTestEnv(TTestActorRuntime& runtime, const TTe
535535
app.SetEnableChangefeedDynamoDBStreamsFormat(opts.EnableChangefeedDynamoDBStreamsFormat_);
536536
app.SetEnableChangefeedDebeziumJsonFormat(opts.EnableChangefeedDebeziumJsonFormat_);
537537
app.SetEnableTablePgTypes(opts.EnableTablePgTypes_);
538+
app.SetEnableServerlessExclusiveDynamicNodes(opts.EnableServerlessExclusiveDynamicNodes_);
538539

539540
app.ColumnShardConfig.SetDisabledOnSchemeShard(false);
540541

ydb/core/tx/schemeshard/ut_helpers/test_env.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace NSchemeShardUT_Private {
5757
OPTION(std::optional<bool>, EnableChangefeedDynamoDBStreamsFormat, std::nullopt);
5858
OPTION(std::optional<bool>, EnableChangefeedDebeziumJsonFormat, std::nullopt);
5959
OPTION(std::optional<bool>, EnableTablePgTypes, std::nullopt);
60+
OPTION(std::optional<bool>, EnableServerlessExclusiveDynamicNodes, std::nullopt);
6061

6162
#undef OPTION
6263
};

ydb/core/tx/schemeshard/ut_serverless/ut_serverless.cpp

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) {
255255

256256
Y_UNIT_TEST(TestServerlessComputeResourcesMode) {
257257
TTestBasicRuntime runtime;
258-
TTestEnv env(runtime);
258+
TTestEnv env(runtime, TTestEnvOptions().EnableServerlessExclusiveDynamicNodes(true));
259259
ui64 txId = 100;
260260

261261
TestCreateExtSubDomain(runtime, ++txId, "/MyRoot",
@@ -359,7 +359,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) {
359359

360360
Y_UNIT_TEST(TestServerlessComputeResourcesModeValidation) {
361361
TTestBasicRuntime runtime;
362-
TTestEnv env(runtime);
362+
TTestEnv env(runtime, TTestEnvOptions().EnableServerlessExclusiveDynamicNodes(true));
363363
ui64 txId = 100;
364364

365365
TestCreateExtSubDomain(runtime, ++txId, "/MyRoot",
@@ -431,9 +431,80 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) {
431431
TestAlterExtSubDomain(runtime, ++txId, "/MyRoot",
432432
R"(
433433
ServerlessComputeResourcesMode: SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED
434-
Name: "SharedDB"
434+
Name: "ServerLess0"
435435
)",
436436
{{ TEvSchemeShard::EStatus::StatusInvalidParameter, "SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED" }}
437437
);
438438
}
439+
440+
441+
Y_UNIT_TEST(TestServerlessComputeResourcesModeFeatureFlag) {
442+
TTestBasicRuntime runtime;
443+
TTestEnv env(runtime, TTestEnvOptions().EnableServerlessExclusiveDynamicNodes(false));
444+
ui64 txId = 100;
445+
446+
TestCreateExtSubDomain(runtime, ++txId, "/MyRoot",
447+
R"(Name: "SharedDB")"
448+
);
449+
env.TestWaitNotification(runtime, txId);
450+
451+
TestAlterExtSubDomain(runtime, ++txId, "/MyRoot",
452+
R"(
453+
StoragePools {
454+
Name: "pool-1"
455+
Kind: "pool-kind-1"
456+
}
457+
StoragePools {
458+
Name: "pool-2"
459+
Kind: "pool-kind-2"
460+
}
461+
PlanResolution: 50
462+
Coordinators: 1
463+
Mediators: 1
464+
TimeCastBucketsPerMediator: 2
465+
ExternalSchemeShard: true
466+
ExternalHive: true
467+
Name: "SharedDB"
468+
)"
469+
);
470+
env.TestWaitNotification(runtime, txId);
471+
472+
TString createData = Sprintf(
473+
R"(
474+
ResourcesDomainKey {
475+
SchemeShard: %lu
476+
PathId: 2
477+
}
478+
Name: "ServerLess0"
479+
)",
480+
TTestTxConfig::SchemeShard
481+
);
482+
TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", createData);
483+
env.TestWaitNotification(runtime, txId);
484+
485+
TestAlterExtSubDomain(runtime, ++txId, "/MyRoot",
486+
R"(
487+
PlanResolution: 50
488+
Coordinators: 1
489+
Mediators: 1
490+
TimeCastBucketsPerMediator: 2
491+
ExternalSchemeShard: true
492+
ExternalHive: false
493+
StoragePools {
494+
Name: "pool-1"
495+
Kind: "pool-kind-1"
496+
}
497+
Name: "ServerLess0"
498+
)"
499+
);
500+
env.TestWaitNotification(runtime, txId);
501+
502+
TestAlterExtSubDomain(runtime, ++txId, "/MyRoot",
503+
R"(
504+
ServerlessComputeResourcesMode: SERVERLESS_COMPUTE_RESOURCES_MODE_DEDICATED
505+
Name: "ServerLess0"
506+
)",
507+
{{ TEvSchemeShard::EStatus::StatusPreconditionFailed, "Unsupported: feature flag EnableServerlessExclusiveDynamicNodes is off" }}
508+
);
509+
}
439510
}

ydb/core/tx/schemeshard/ut_serverless_reboots/ut_serverless_reboots.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLessReboots) {
4040

4141
Y_UNIT_TEST(TestServerlessComputeResourcesModeWithReboots) {
4242
TTestWithReboots t;
43+
t.GetTestEnvOptions().EnableServerlessExclusiveDynamicNodes(true);
44+
4345
t.Run([&](TTestActorRuntime& runtime, bool& activeZone) {
4446
ui64 sharedHive = 0;
4547
ui64 tenantSchemeShard = 0;

0 commit comments

Comments
 (0)