aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpixcc <pixcc@yandex-team.com>2023-11-24 09:29:11 +0300
committerpixcc <pixcc@yandex-team.com>2023-11-24 09:50:56 +0300
commit5989f432e9a3d92e28572d2c2ba7b8f7179b1b63 (patch)
treebe43a94101f8d45bc5b27f65580491029b22839c
parent61d380beacde734e41d65d5404742fccc9f6f4b3 (diff)
downloadydb-5989f432e9a3d92e28572d2c2ba7b8f7179b1b63.tar.gz
Add ServerlessComputeResourcesMode to scheme KIKIMR-20111
Add ServerlessComputeResourcesMode to scheme KIKIMR-20111
-rw-r--r--.mapping.json6
-rw-r--r--ydb/core/protos/flat_tx_scheme.proto2
-rw-r--r--ydb/core/protos/out/out.cpp4
-rw-r--r--ydb/core/protos/subdomains.proto8
-rw-r--r--ydb/core/tx/schemeshard/CMakeLists.darwin-arm64.txt1
-rw-r--r--ydb/core/tx/schemeshard/CMakeLists.darwin-x86_64.txt1
-rw-r--r--ydb/core/tx/schemeshard/CMakeLists.linux-aarch64.txt1
-rw-r--r--ydb/core/tx/schemeshard/CMakeLists.linux-x86_64.txt1
-rw-r--r--ydb/core/tx/schemeshard/CMakeLists.windows-x86_64.txt1
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__init.cpp12
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__init_root.cpp4
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp36
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_common_subdomain.h3
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_side_effects.cpp3
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__sync_update_tenants.cpp5
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_impl.cpp23
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_impl.h2
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_info_types.h14
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_path_describer.cpp4
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_schema.h8
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_types.h2
-rw-r--r--ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp13
-rw-r--r--ydb/core/tx/schemeshard/ut_helpers/ls_checks.h1
-rw-r--r--ydb/core/tx/schemeshard/ut_serverless/ut_serverless.cpp179
-rw-r--r--ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.darwin-arm64.txt83
-rw-r--r--ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.darwin-x86_64.txt84
-rw-r--r--ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.linux-aarch64.txt87
-rw-r--r--ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.linux-x86_64.txt89
-rw-r--r--ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.txt19
-rw-r--r--ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.windows-x86_64.txt77
-rw-r--r--ydb/core/tx/schemeshard/ut_serverless_reboots/ut_serverless_reboots.cpp150
-rw-r--r--ydb/core/tx/schemeshard/ut_serverless_reboots/ya.make30
-rw-r--r--ydb/core/tx/schemeshard/ya.make1
-rw-r--r--ydb/tests/functional/scheme_tests/canondata/tablet_scheme_tests.TestTabletSchemes.test_tablet_schemes_flat_schemeshard_/flat_schemeshard.schema16
34 files changed, 959 insertions, 11 deletions
diff --git a/.mapping.json b/.mapping.json
index b2d3fb8a1c..54a8b17067 100644
--- a/.mapping.json
+++ b/.mapping.json
@@ -7241,6 +7241,12 @@
"ydb/core/tx/schemeshard/ut_serverless/CMakeLists.linux-x86_64.txt":"",
"ydb/core/tx/schemeshard/ut_serverless/CMakeLists.txt":"",
"ydb/core/tx/schemeshard/ut_serverless/CMakeLists.windows-x86_64.txt":"",
+ "ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.darwin-arm64.txt":"",
+ "ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.darwin-x86_64.txt":"",
+ "ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.linux-aarch64.txt":"",
+ "ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.linux-x86_64.txt":"",
+ "ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.txt":"",
+ "ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.windows-x86_64.txt":"",
"ydb/core/tx/schemeshard/ut_split_merge/CMakeLists.darwin-arm64.txt":"",
"ydb/core/tx/schemeshard/ut_split_merge/CMakeLists.darwin-x86_64.txt":"",
"ydb/core/tx/schemeshard/ut_split_merge/CMakeLists.linux-aarch64.txt":"",
diff --git a/ydb/core/protos/flat_tx_scheme.proto b/ydb/core/protos/flat_tx_scheme.proto
index aec23c5293..eaaec9918f 100644
--- a/ydb/core/protos/flat_tx_scheme.proto
+++ b/ydb/core/protos/flat_tx_scheme.proto
@@ -212,6 +212,7 @@ message TEvInitTenantSchemeShard {
optional NKikimrSubDomains.TSchemeQuotas DeclaredSchemeQuotas = 16;
optional Ydb.Cms.DatabaseQuotas DatabaseQuotas = 17;
optional NKikimrSubDomains.TAuditSettings AuditSettings = 18;
+ optional NKikimrSubDomains.EServerlessComputeResourcesMode ServerlessComputeResourcesMode = 19;
}
message TEvInitTenantSchemeShardResult {
@@ -383,6 +384,7 @@ message TEvUpdateTenantSchemeShard {
optional string UpdateTenantRootACL = 13;
optional NKikimrSubDomains.TAuditSettings AuditSettings = 15;
+ optional NKikimrSubDomains.EServerlessComputeResourcesMode ServerlessComputeResourcesMode = 17;
}
message TEvFindTabletSubDomainPathId {
diff --git a/ydb/core/protos/out/out.cpp b/ydb/core/protos/out/out.cpp
index 76c8825777..bec7401ad4 100644
--- a/ydb/core/protos/out/out.cpp
+++ b/ydb/core/protos/out/out.cpp
@@ -216,3 +216,7 @@ Y_DECLARE_OUT_SPEC(, NKikimrSchemeOp::ECdcStreamFormat, stream, value) {
Y_DECLARE_OUT_SPEC(, NKikimrSchemeOp::ECdcStreamState, stream, value) {
stream << NKikimrSchemeOp::ECdcStreamState_Name(value);
}
+
+Y_DECLARE_OUT_SPEC(, NKikimrSubDomains::EServerlessComputeResourcesMode, stream, value) {
+ stream << NKikimrSubDomains::EServerlessComputeResourcesMode_Name(value);
+}
diff --git a/ydb/core/protos/subdomains.proto b/ydb/core/protos/subdomains.proto
index 52e1f2ad98..cafd60f519 100644
--- a/ydb/core/protos/subdomains.proto
+++ b/ydb/core/protos/subdomains.proto
@@ -19,6 +19,7 @@ message TSubDomainSettings {
optional bool ExternalSchemeShard = 7 [default = false];
optional bool ExternalHive = 8 [default = false];
optional TDomainKey ResourcesDomainKey = 9;
+ optional EServerlessComputeResourcesMode ServerlessComputeResourcesMode = 15;
optional bool ExternalSysViewProcessor = 10 [default = false];
optional TSchemeQuotas DeclaredSchemeQuotas = 11;
optional Ydb.Cms.DatabaseQuotas DatabaseQuotas = 12;
@@ -87,6 +88,7 @@ message TDomainDescription {
optional uint64 ShardsLimit = 9;
optional TDomainKey ResourcesDomainKey = 10;
+ optional EServerlessComputeResourcesMode ServerlessComputeResourcesMode = 23;
optional TDiskSpaceUsage DiskSpaceUsage = 11; // TODO: temp for SLYDB-95
@@ -112,3 +114,9 @@ message TSchemeQuota {
optional double BucketSize = 1;
optional uint64 BucketSeconds = 2;
}
+
+enum EServerlessComputeResourcesMode {
+ SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED = 0;
+ SERVERLESS_COMPUTE_RESOURCES_MODE_SHARED = 1; // using nodes that serve resources domain
+ SERVERLESS_COMPUTE_RESOURCES_MODE_DEDICATED = 2; // using nodes that serve self domain
+}
diff --git a/ydb/core/tx/schemeshard/CMakeLists.darwin-arm64.txt b/ydb/core/tx/schemeshard/CMakeLists.darwin-arm64.txt
index e69d303b7a..8b543a8196 100644
--- a/ydb/core/tx/schemeshard/CMakeLists.darwin-arm64.txt
+++ b/ydb/core/tx/schemeshard/CMakeLists.darwin-arm64.txt
@@ -45,6 +45,7 @@ add_subdirectory(ut_ru_calculator)
add_subdirectory(ut_sequence)
add_subdirectory(ut_sequence_reboots)
add_subdirectory(ut_serverless)
+add_subdirectory(ut_serverless_reboots)
add_subdirectory(ut_split_merge)
add_subdirectory(ut_split_merge_reboots)
add_subdirectory(ut_stats)
diff --git a/ydb/core/tx/schemeshard/CMakeLists.darwin-x86_64.txt b/ydb/core/tx/schemeshard/CMakeLists.darwin-x86_64.txt
index e69d303b7a..8b543a8196 100644
--- a/ydb/core/tx/schemeshard/CMakeLists.darwin-x86_64.txt
+++ b/ydb/core/tx/schemeshard/CMakeLists.darwin-x86_64.txt
@@ -45,6 +45,7 @@ add_subdirectory(ut_ru_calculator)
add_subdirectory(ut_sequence)
add_subdirectory(ut_sequence_reboots)
add_subdirectory(ut_serverless)
+add_subdirectory(ut_serverless_reboots)
add_subdirectory(ut_split_merge)
add_subdirectory(ut_split_merge_reboots)
add_subdirectory(ut_stats)
diff --git a/ydb/core/tx/schemeshard/CMakeLists.linux-aarch64.txt b/ydb/core/tx/schemeshard/CMakeLists.linux-aarch64.txt
index 2a9e71ef80..828ad3b71c 100644
--- a/ydb/core/tx/schemeshard/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/tx/schemeshard/CMakeLists.linux-aarch64.txt
@@ -45,6 +45,7 @@ add_subdirectory(ut_ru_calculator)
add_subdirectory(ut_sequence)
add_subdirectory(ut_sequence_reboots)
add_subdirectory(ut_serverless)
+add_subdirectory(ut_serverless_reboots)
add_subdirectory(ut_split_merge)
add_subdirectory(ut_split_merge_reboots)
add_subdirectory(ut_stats)
diff --git a/ydb/core/tx/schemeshard/CMakeLists.linux-x86_64.txt b/ydb/core/tx/schemeshard/CMakeLists.linux-x86_64.txt
index 2a9e71ef80..828ad3b71c 100644
--- a/ydb/core/tx/schemeshard/CMakeLists.linux-x86_64.txt
+++ b/ydb/core/tx/schemeshard/CMakeLists.linux-x86_64.txt
@@ -45,6 +45,7 @@ add_subdirectory(ut_ru_calculator)
add_subdirectory(ut_sequence)
add_subdirectory(ut_sequence_reboots)
add_subdirectory(ut_serverless)
+add_subdirectory(ut_serverless_reboots)
add_subdirectory(ut_split_merge)
add_subdirectory(ut_split_merge_reboots)
add_subdirectory(ut_stats)
diff --git a/ydb/core/tx/schemeshard/CMakeLists.windows-x86_64.txt b/ydb/core/tx/schemeshard/CMakeLists.windows-x86_64.txt
index b27ba39942..d4f0e42a7d 100644
--- a/ydb/core/tx/schemeshard/CMakeLists.windows-x86_64.txt
+++ b/ydb/core/tx/schemeshard/CMakeLists.windows-x86_64.txt
@@ -45,6 +45,7 @@ add_subdirectory(ut_ru_calculator)
add_subdirectory(ut_sequence)
add_subdirectory(ut_sequence_reboots)
add_subdirectory(ut_serverless)
+add_subdirectory(ut_serverless_reboots)
add_subdirectory(ut_split_merge)
add_subdirectory(ut_split_merge_reboots)
add_subdirectory(ut_stats)
diff --git a/ydb/core/tx/schemeshard/schemeshard__init.cpp b/ydb/core/tx/schemeshard/schemeshard__init.cpp
index 3a81e088d2..9d8aebd4de 100644
--- a/ydb/core/tx/schemeshard/schemeshard__init.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__init.cpp
@@ -1530,6 +1530,12 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> {
Y_ABORT_UNLESS(ParseFromStringNoSizeLimit(value, rowset.GetValue<Schema::SubDomains::AuditSettings>()));
domainInfo->SetAuditSettings(value);
}
+
+ if (rowset.HaveValue<Schema::SubDomains::ServerlessComputeResourcesMode>()) {
+ domainInfo->SetServerlessComputeResourcesMode(
+ rowset.GetValue<Schema::SubDomains::ServerlessComputeResourcesMode>()
+ );
+ }
}
if (!rowset.Next())
@@ -1593,6 +1599,12 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> {
alter->SetDatabaseQuotas(databaseQuotas);
}
+ if (rowset.HaveValue<Schema::SubDomainsAlterData::ServerlessComputeResourcesMode>()) {
+ alter->SetServerlessComputeResourcesMode(
+ rowset.GetValue<Schema::SubDomainsAlterData::ServerlessComputeResourcesMode>()
+ );
+ }
+
subdomainInfo->SetAlter(alter);
if (!rowset.Next())
diff --git a/ydb/core/tx/schemeshard/schemeshard__init_root.cpp b/ydb/core/tx/schemeshard/schemeshard__init_root.cpp
index e37b88c889..6b9d51a8b4 100644
--- a/ydb/core/tx/schemeshard/schemeshard__init_root.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__init_root.cpp
@@ -396,6 +396,10 @@ struct TSchemeShard::TTxInitTenantSchemeShard : public TSchemeShard::TRwTxBase {
subdomain->SetAuditSettings(record.GetAuditSettings());
}
+ if (record.HasServerlessComputeResourcesMode()) {
+ subdomain->SetServerlessComputeResourcesMode(record.GetServerlessComputeResourcesMode());
+ }
+
RegisterShard(db, subdomain, processingParams.GetCoordinators(), TTabletTypes::Coordinator);
RegisterShard(db, subdomain, processingParams.GetMediators(), TTabletTypes::Mediator);
RegisterShard(db, subdomain, TVector<ui64>{processingParams.GetSchemeShard()}, TTabletTypes::SchemeShard);
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp
index dfcf35ae54..3150caded0 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp
@@ -42,7 +42,8 @@ struct TParamsDelta {
};
std::tuple<NKikimrScheme::EStatus, TString>
-VerifyParams(TParamsDelta* delta, const TSubDomainInfo::TPtr& current, const NKikimrSubDomains::TSubDomainSettings& input) {
+VerifyParams(TParamsDelta* delta, const TPathId pathId, const TSubDomainInfo::TPtr& current,
+ const NKikimrSubDomains::TSubDomainSettings& input) {
auto paramError = [](const TStringBuf& msg) {
return std::make_tuple(NKikimrScheme::EStatus::StatusInvalidParameter,
TStringBuilder() << "Invalid ExtSubDomain request: " << msg
@@ -245,6 +246,24 @@ VerifyParams(TParamsDelta* delta, const TSubDomainInfo::TPtr& current, const NKi
std::back_inserter(storagePoolsAdded));
}
+ // ServerlessComputeResourcesMode check
+ if (input.HasServerlessComputeResourcesMode()) {
+ switch (input.GetServerlessComputeResourcesMode()) {
+ case EServerlessComputeResourcesMode::SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED:
+ return paramError("can not set ServerlessComputeResourcesMode to SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED");
+ case EServerlessComputeResourcesMode::SERVERLESS_COMPUTE_RESOURCES_MODE_DEDICATED:
+ case EServerlessComputeResourcesMode::SERVERLESS_COMPUTE_RESOURCES_MODE_SHARED:
+ break; // ok
+ default:
+ return paramError("unknown ServerlessComputeResourcesMode");
+ }
+
+ const bool isServerless = pathId != current->GetResourcesDomainId();
+ if (!isServerless) {
+ return paramError("ServerlessComputeResourcesMode can be changed only for serverless");
+ }
+ }
+
delta->CoordinatorsAdded = coordinatorsAdded;
delta->MediatorsAdded = mediatorsAdded;
delta->TimeCastBucketsPerMediatorAdded = timeCastBucketsPerMediatorAdded;
@@ -258,10 +277,11 @@ VerifyParams(TParamsDelta* delta, const TSubDomainInfo::TPtr& current, const NKi
return {NKikimrScheme::EStatus::StatusAccepted, {}};
}
-void VerifyParams(TProposeResponse* result, TParamsDelta* delta, const TSubDomainInfo::TPtr& current, const NKikimrSubDomains::TSubDomainSettings& input) {
+void VerifyParams(TProposeResponse* result, TParamsDelta* delta, const TPathId pathId,
+ const TSubDomainInfo::TPtr& current, const NKikimrSubDomains::TSubDomainSettings& input) {
// TProposeRespose should come in assuming positive outcome (status NKikimrScheme::StatusAccepted, no errors)
Y_ABORT_UNLESS(result->IsAccepted());
- auto [status, reason] = VerifyParams(delta, current, input);
+ auto [status, reason] = VerifyParams(delta, pathId, current, input);
result->SetStatus(status, reason);
}
@@ -570,7 +590,7 @@ public:
// Check params and build change delta
TParamsDelta delta;
- VerifyParams(result.Get(), &delta, subdomainInfo, inputSettings);
+ VerifyParams(result.Get(), &delta, basenameId, subdomainInfo, inputSettings);
if (!result->IsAccepted()) {
return result;
}
@@ -751,7 +771,7 @@ public:
// Check params and build change delta
TParamsDelta delta;
- VerifyParams(result.Get(), &delta, subdomainInfo, inputSettings);
+ VerifyParams(result.Get(), &delta, basenameId, subdomainInfo, inputSettings);
if (!result->IsAccepted()) {
return result;
}
@@ -818,6 +838,10 @@ public:
alter->ApplyAuditSettings(inputSettings.GetAuditSettings());
}
+ if (inputSettings.HasServerlessComputeResourcesMode()) {
+ alter->SetServerlessComputeResourcesMode(inputSettings.GetServerlessComputeResourcesMode());
+ }
+
LOG_D("TAlterExtSubDomain Propose"
<< ", opId: " << OperationId
<< ", subdomain ver " << subdomainInfo->GetVersion()
@@ -988,7 +1012,7 @@ TVector<ISubOperation::TPtr> CreateCompatibleAlterExtSubDomain(TOperationId id,
// Check params and build change delta
TParamsDelta delta;
{
- auto [status, reason] = VerifyParams(&delta, subdomainInfo, inputSettings);
+ auto [status, reason] = VerifyParams(&delta, basenameId, subdomainInfo, inputSettings);
if (status != NKikimrScheme::EStatus::StatusAccepted) {
return errorResult(status, reason);
}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_common_subdomain.h b/ydb/core/tx/schemeshard/schemeshard__operation_common_subdomain.h
index 59a1581128..9f4cf9b22c 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_common_subdomain.h
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_common_subdomain.h
@@ -245,6 +245,9 @@ public:
if (alterData->GetAuditSettings()) {
event->Record.MutableAuditSettings()->CopyFrom(*alterData->GetAuditSettings());
}
+ if (alterData->GetServerlessComputeResourcesMode()) {
+ event->Record.SetServerlessComputeResourcesMode(*alterData->GetServerlessComputeResourcesMode());
+ }
LOG_DEBUG_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
"Send configure request to schemeshard: " << tabletID <<
" opId: " << OperationId <<
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_side_effects.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_side_effects.cpp
index b2225650df..5f5022967f 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_side_effects.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_side_effects.cpp
@@ -456,6 +456,9 @@ void TSideEffects::DoUpdateTenant(TSchemeShard* ss, NTabletFlatExecutor::TTransa
if (const auto& auditSettings = subDomain->GetAuditSettings()) {
message->Record.MutableAuditSettings()->CopyFrom(*auditSettings);
}
+ if (const auto& serverlessComputeResourcesMode = subDomain->GetServerlessComputeResourcesMode()) {
+ message->Record.SetServerlessComputeResourcesMode(*serverlessComputeResourcesMode);
+ }
hasChanges = true;
}
diff --git a/ydb/core/tx/schemeshard/schemeshard__sync_update_tenants.cpp b/ydb/core/tx/schemeshard/schemeshard__sync_update_tenants.cpp
index 81df25fee1..9d75aacb1f 100644
--- a/ydb/core/tx/schemeshard/schemeshard__sync_update_tenants.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__sync_update_tenants.cpp
@@ -118,6 +118,11 @@ struct TSchemeShard::TTxUpdateTenant : public TSchemeShard::TRwTxBase {
Self->PersistSubDomainAuditSettings(db, Self->RootPathId(), *subdomain);
}
+ if (record.HasServerlessComputeResourcesMode()) {
+ subdomain->SetServerlessComputeResourcesMode(record.GetServerlessComputeResourcesMode());
+ Self->PersistSubDomainServerlessComputeResourcesMode(db, Self->RootPathId(), *subdomain);
+ }
+
Self->PersistStoragePools(db, Self->RootPathId(), *subdomain);
SideEffects.PublishToSchemeBoard(InvalidOperationId, Self->RootPathId());
MakeSync();
diff --git a/ydb/core/tx/schemeshard/schemeshard_impl.cpp b/ydb/core/tx/schemeshard/schemeshard_impl.cpp
index df5db089f8..3f7e93f9d9 100644
--- a/ydb/core/tx/schemeshard/schemeshard_impl.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard_impl.cpp
@@ -1881,6 +1881,7 @@ void TSchemeShard::PersistSubDomainAlter(NIceDb::TNiceDb& db, const TPathId& pat
}
PersistSubDomainAuditSettingsAlter(db, pathId, subDomain);
+ PersistSubDomainServerlessComputeResourcesModeAlter(db, pathId, subDomain);
for (auto shardIdx: subDomain.GetPrivateShards()) {
db.Table<Schema::SubDomainShardsAlterData>().Key(pathId.LocalPathId, shardIdx.GetLocalId()).Update();
@@ -1944,6 +1945,7 @@ void TSchemeShard::PersistSubDomain(NIceDb::TNiceDb& db, const TPathId& pathId,
PersistSubDomainState(db, pathId, subDomain);
PersistSubDomainAuditSettings(db, pathId, subDomain);
+ PersistSubDomainServerlessComputeResourcesMode(db, pathId, subDomain);
db.Table<Schema::SubDomainsAlterData>().Key(pathId.LocalPathId).Delete();
@@ -2066,6 +2068,27 @@ void TSchemeShard::PersistSubDomainAuditSettingsAlter(NIceDb::TNiceDb& db, const
PersistSubDomainAuditSettingsImpl<Schema::SubDomainsAlterData>(db, pathId, subDomain.GetAuditSettings());
}
+template <class Table>
+void PersistSubDomainServerlessComputeResourcesModeImpl(NIceDb::TNiceDb& db, const TPathId& pathId,
+ const TSubDomainInfo::TMaybeServerlessComputeResourcesMode& value) {
+ using Field = typename Table::ServerlessComputeResourcesMode;
+ if (value) {
+ db.Table<Table>().Key(pathId.LocalPathId).Update(NIceDb::TUpdate<Field>(*value));
+ }
+}
+
+void TSchemeShard::PersistSubDomainServerlessComputeResourcesMode(NIceDb::TNiceDb& db, const TPathId& pathId,
+ const TSubDomainInfo& subDomain) {
+ const auto& serverlessComputeResourcesMode = subDomain.GetServerlessComputeResourcesMode();
+ PersistSubDomainServerlessComputeResourcesModeImpl<Schema::SubDomains>(db, pathId, serverlessComputeResourcesMode);
+}
+
+void TSchemeShard::PersistSubDomainServerlessComputeResourcesModeAlter(NIceDb::TNiceDb& db, const TPathId& pathId,
+ const TSubDomainInfo& subDomain) {
+ const auto& serverlessComputeResourcesMode = subDomain.GetServerlessComputeResourcesMode();
+ PersistSubDomainServerlessComputeResourcesModeImpl<Schema::SubDomainsAlterData>(db, pathId, serverlessComputeResourcesMode);
+}
+
void TSchemeShard::PersistACL(NIceDb::TNiceDb& db, const TPathElement::TPtr path) {
if (path->PathId.OwnerId == TabletID()) {
db.Table<Schema::Paths>().Key(path->PathId.LocalPathId).Update(
diff --git a/ydb/core/tx/schemeshard/schemeshard_impl.h b/ydb/core/tx/schemeshard/schemeshard_impl.h
index b12b29395f..47fc928848 100644
--- a/ydb/core/tx/schemeshard/schemeshard_impl.h
+++ b/ydb/core/tx/schemeshard/schemeshard_impl.h
@@ -664,6 +664,8 @@ public:
void PersistDeleteSubDomainAlter(NIceDb::TNiceDb& db, const TPathId& pathId, const TSubDomainInfo& subDomain);
void PersistSubDomainAuditSettings(NIceDb::TNiceDb& db, const TPathId& pathId, const TSubDomainInfo& subDomain);
void PersistSubDomainAuditSettingsAlter(NIceDb::TNiceDb& db, const TPathId& pathId, const TSubDomainInfo& subDomain);
+ void PersistSubDomainServerlessComputeResourcesMode(NIceDb::TNiceDb& db, const TPathId& pathId, const TSubDomainInfo& subDomain);
+ void PersistSubDomainServerlessComputeResourcesModeAlter(NIceDb::TNiceDb& db, const TPathId& pathId, const TSubDomainInfo& subDomain);
void PersistKesusInfo(NIceDb::TNiceDb& db, TPathId pathId, const TKesusInfo::TPtr);
void PersistKesusVersion(NIceDb::TNiceDb& db, TPathId pathId, const TKesusInfo::TPtr);
void PersistAddKesusAlter(NIceDb::TNiceDb& db, TPathId pathId, const TKesusInfo::TPtr);
diff --git a/ydb/core/tx/schemeshard/schemeshard_info_types.h b/ydb/core/tx/schemeshard/schemeshard_info_types.h
index 87a55d4034..58c7317664 100644
--- a/ydb/core/tx/schemeshard/schemeshard_info_types.h
+++ b/ydb/core/tx/schemeshard/schemeshard_info_types.h
@@ -2134,6 +2134,17 @@ struct TSubDomainInfo: TSimpleRefCount<TSubDomainInfo> {
void ApplyAuditSettings(const TMaybeAuditSettings& diff);
+ using TMaybeServerlessComputeResourcesMode = TMaybe<EServerlessComputeResourcesMode, NMaybe::TPolicyUndefinedFail>;
+
+ const TMaybeServerlessComputeResourcesMode& GetServerlessComputeResourcesMode() const {
+ return ServerlessComputeResourcesMode;
+ }
+
+ void SetServerlessComputeResourcesMode(EServerlessComputeResourcesMode serverlessComputeResourcesMode) {
+ Y_ABORT_UNLESS(serverlessComputeResourcesMode, "Can't set ServerlessComputeResourcesMode to unspecified");
+ ServerlessComputeResourcesMode = serverlessComputeResourcesMode;
+ }
+
private:
bool InitiatedAsGlobal = false;
NKikimrSubDomains::TProcessingParams ProcessingParams;
@@ -2163,7 +2174,8 @@ private:
TPathId ResourcesDomainId;
TTabletId SharedHive = InvalidTabletId;
-
+ TMaybeServerlessComputeResourcesMode ServerlessComputeResourcesMode;
+
NLoginProto::TSecurityState SecurityState;
ui64 SecurityStateVersion = 0;
diff --git a/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp b/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp
index b7abb4fbc3..301ade3339 100644
--- a/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp
@@ -713,6 +713,10 @@ void TPathDescriber::DescribeDomainRoot(TPathElement::TPtr pathEl) {
entry->MutableAuditSettings()->CopyFrom(*auditSettings);
}
+ if (const auto& serverlessComputeResourcesMode = subDomainInfo->GetServerlessComputeResourcesMode()) {
+ entry->SetServerlessComputeResourcesMode(*serverlessComputeResourcesMode);
+ }
+
if (TTabletId sharedHive = subDomainInfo->GetSharedHive()) {
entry->SetSharedHive(sharedHive.GetValue());
}
diff --git a/ydb/core/tx/schemeshard/schemeshard_schema.h b/ydb/core/tx/schemeshard/schemeshard_schema.h
index 009229dbac..612d7aa6bf 100644
--- a/ydb/core/tx/schemeshard/schemeshard_schema.h
+++ b/ydb/core/tx/schemeshard/schemeshard_schema.h
@@ -735,6 +735,7 @@ struct Schema : NIceDb::Schema {
struct ExportsLimit : Column<28, NScheme::NTypeIds::Uint64> {};
struct ImportsLimit : Column<29, NScheme::NTypeIds::Uint64> {};
struct AuditSettings : Column<30, NScheme::NTypeIds::String> {};
+ struct ServerlessComputeResourcesMode : Column<31, NScheme::NTypeIds::Uint32> { using Type = EServerlessComputeResourcesMode; };
using TKey = TableKey<PathId>;
using TColumns = TableColumns<
@@ -767,7 +768,8 @@ struct Schema : NIceDb::Schema {
TableCdcStreamsLimit,
ExportsLimit,
ImportsLimit,
- AuditSettings
+ AuditSettings,
+ ServerlessComputeResourcesMode
>;
};
@@ -790,6 +792,7 @@ struct Schema : NIceDb::Schema {
struct DeclaredSchemeQuotas : Column<8, NScheme::NTypeIds::String> {};
struct DatabaseQuotas : Column<9, NScheme::NTypeIds::String> {};
struct AuditSettings : Column<10, NScheme::NTypeIds::String> {};
+ struct ServerlessComputeResourcesMode : Column<11, NScheme::NTypeIds::Uint32> { using Type = EServerlessComputeResourcesMode; };
using TKey = TableKey<PathId>;
using TColumns = TableColumns<
@@ -802,7 +805,8 @@ struct Schema : NIceDb::Schema {
SharedHiveId,
DeclaredSchemeQuotas,
DatabaseQuotas,
- AuditSettings
+ AuditSettings,
+ ServerlessComputeResourcesMode
>;
};
diff --git a/ydb/core/tx/schemeshard/schemeshard_types.h b/ydb/core/tx/schemeshard/schemeshard_types.h
index 437bd11258..e59d048279 100644
--- a/ydb/core/tx/schemeshard/schemeshard_types.h
+++ b/ydb/core/tx/schemeshard/schemeshard_types.h
@@ -136,4 +136,6 @@ enum class EAttachChildResult : ui32 {
RejectAsNewerUnCreated
};
+using EServerlessComputeResourcesMode = NKikimrSubDomains::EServerlessComputeResourcesMode;
+
}
diff --git a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp
index 9865e71fab..631e2624f8 100644
--- a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp
+++ b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp
@@ -1164,6 +1164,19 @@ TCheckFunc PartitionKeys(TVector<TString> lastShardKeys) {
};
}
+TCheckFunc ServerlessComputeResourcesMode(NKikimrSubDomains::EServerlessComputeResourcesMode serverlessComputeResourcesMode) {
+ return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) {
+ UNIT_ASSERT_C(IsGoodDomainStatus(record.GetStatus()), "Unexpected status: " << record.GetStatus());
+
+ const auto& domainDesc = record.GetPathDescription().GetDomainDescription();
+ if (serverlessComputeResourcesMode) {
+ UNIT_ASSERT_VALUES_EQUAL(domainDesc.GetServerlessComputeResourcesMode(), serverlessComputeResourcesMode);
+ } else {
+ UNIT_ASSERT(!domainDesc.HasServerlessComputeResourcesMode());
+ }
+ };
+}
+
#undef DESCRIBE_ASSERT_EQUAL
} // NLs
diff --git a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h
index caaf236410..88f1794a20 100644
--- a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h
+++ b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h
@@ -149,6 +149,7 @@ namespace NLs {
TCheckFunc KesusConfigIs(ui64 self_check_period_millis, ui64 session_grace_period_millis);
TCheckFunc DatabaseQuotas(ui64 dataStreamShards);
TCheckFunc SharedHive(ui64 sharedHiveId);
+ TCheckFunc ServerlessComputeResourcesMode(NKikimrSubDomains::EServerlessComputeResourcesMode serverlessComputeResourcesMode);
template<class TCheck>
void PerformAllChecks(const NKikimrScheme::TEvDescribeSchemeResult& result, TCheck&& check) {
diff --git a/ydb/core/tx/schemeshard/ut_serverless/ut_serverless.cpp b/ydb/core/tx/schemeshard/ut_serverless/ut_serverless.cpp
index d4ce247259..2c9827bfcc 100644
--- a/ydb/core/tx/schemeshard/ut_serverless/ut_serverless.cpp
+++ b/ydb/core/tx/schemeshard/ut_serverless/ut_serverless.cpp
@@ -7,6 +7,8 @@ using namespace NKikimr;
using namespace NSchemeShard;
using namespace NSchemeShardUT_Private;
+using enum NKikimrSubDomains::EServerlessComputeResourcesMode;
+
Y_UNIT_TEST_SUITE(TSchemeShardServerLess) {
Y_UNIT_TEST(Fake) {
}
@@ -250,4 +252,181 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) {
UNIT_ASSERT_NO_DIFF(meteringMessages, meteringData);
}
}
+
+ Y_UNIT_TEST(TestServerlessComputeResourcesMode) {
+ TTestBasicRuntime runtime;
+ TTestEnv env(runtime);
+ 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);
+
+ ui64 tenantSchemeShard = 0;
+ TestDescribeResult(DescribePath(runtime, "/MyRoot/ServerLess0"),
+ {NLs::PathExist,
+ NLs::IsExternalSubDomain("ServerLess0"),
+ NLs::ServerlessComputeResourcesMode(SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED),
+ NLs::ExtractTenantSchemeshard(&tenantSchemeShard)});
+
+ UNIT_ASSERT(tenantSchemeShard != 0
+ && tenantSchemeShard != (ui64)-1
+ && tenantSchemeShard != TTestTxConfig::SchemeShard);
+
+ TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/ServerLess0"),
+ {NLs::PathExist,
+ NLs::ServerlessComputeResourcesMode(SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED)});
+
+ auto checkServerlessComputeResourcesMode = [&](EServerlessComputeResourcesMode serverlessComputeResourcesMode) {
+ TString alterData = Sprintf(
+ R"(
+ ServerlessComputeResourcesMode: %d
+ Name: "ServerLess0"
+ )",
+ serverlessComputeResourcesMode
+ );
+ TestAlterExtSubDomain(runtime, ++txId, "/MyRoot", alterData);
+ env.TestWaitNotification(runtime, txId);
+
+ TestDescribeResult(DescribePath(runtime, "/MyRoot/ServerLess0"),
+ {NLs::ServerlessComputeResourcesMode(serverlessComputeResourcesMode)});
+ TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/ServerLess0"),
+ {NLs::ServerlessComputeResourcesMode(serverlessComputeResourcesMode)});
+ };
+
+ checkServerlessComputeResourcesMode(SERVERLESS_COMPUTE_RESOURCES_MODE_DEDICATED);
+ checkServerlessComputeResourcesMode(SERVERLESS_COMPUTE_RESOURCES_MODE_SHARED);
+ }
+
+ Y_UNIT_TEST(TestServerlessComputeResourcesModeValidation) {
+ TTestBasicRuntime runtime;
+ TTestEnv env(runtime);
+ 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);
+
+ // Try to change ServerlessComputeResourcesMode not on serverless database
+ TestAlterExtSubDomain(runtime, ++txId, "/MyRoot",
+ R"(
+ ServerlessComputeResourcesMode: SERVERLESS_COMPUTE_RESOURCES_MODE_SHARED
+ Name: "SharedDB"
+ )",
+ {{ TEvSchemeShard::EStatus::StatusInvalidParameter, "only for serverless" }}
+ );
+
+ // Try to set ServerlessComputeResourcesMode to SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED
+ TestAlterExtSubDomain(runtime, ++txId, "/MyRoot",
+ R"(
+ ServerlessComputeResourcesMode: SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED
+ Name: "SharedDB"
+ )",
+ {{ TEvSchemeShard::EStatus::StatusInvalidParameter, "SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED" }}
+ );
+ }
}
diff --git a/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.darwin-arm64.txt b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.darwin-arm64.txt
new file mode 100644
index 0000000000..7fa8a9462f
--- /dev/null
+++ b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.darwin-arm64.txt
@@ -0,0 +1,83 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-core-tx-schemeshard-ut_serverless_reboots)
+target_compile_options(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_include_directories(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/schemeshard
+)
+target_link_libraries(ydb-core-tx-schemeshard-ut_serverless_reboots PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ cpp-testing-unittest_main
+ core-tx-schemeshard
+ library-cpp-getopt
+ cpp-regex-pcre
+ library-cpp-svnversion
+ core-testlib-default
+ ydb-core-tx
+ tx-schemeshard-ut_helpers
+ ydb-core-yql_testlib
+)
+target_link_options(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ -Wl,-platform_version,macos,11.0,11.0
+ -fPIC
+ -fPIC
+ -framework
+ CoreFoundation
+)
+target_sources(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/schemeshard/ut_serverless_reboots/ut_serverless_reboots.cpp
+)
+set_property(
+ TARGET
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ SPLIT_FACTOR
+ 10
+)
+add_yunittest(
+ NAME
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ TEST_TARGET
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ PROCESSORS
+ 1
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ TIMEOUT
+ 600
+)
+target_allocator(ydb-core-tx-schemeshard-ut_serverless_reboots
+ system_allocator
+)
+vcs_info(ydb-core-tx-schemeshard-ut_serverless_reboots)
diff --git a/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.darwin-x86_64.txt b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.darwin-x86_64.txt
new file mode 100644
index 0000000000..6862513ea3
--- /dev/null
+++ b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.darwin-x86_64.txt
@@ -0,0 +1,84 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-core-tx-schemeshard-ut_serverless_reboots)
+target_compile_options(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_include_directories(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/schemeshard
+)
+target_link_libraries(ydb-core-tx-schemeshard-ut_serverless_reboots PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-unittest_main
+ core-tx-schemeshard
+ library-cpp-getopt
+ cpp-regex-pcre
+ library-cpp-svnversion
+ core-testlib-default
+ ydb-core-tx
+ tx-schemeshard-ut_helpers
+ ydb-core-yql_testlib
+)
+target_link_options(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ -Wl,-platform_version,macos,11.0,11.0
+ -fPIC
+ -fPIC
+ -framework
+ CoreFoundation
+)
+target_sources(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/schemeshard/ut_serverless_reboots/ut_serverless_reboots.cpp
+)
+set_property(
+ TARGET
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ SPLIT_FACTOR
+ 10
+)
+add_yunittest(
+ NAME
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ TEST_TARGET
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ PROCESSORS
+ 1
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ TIMEOUT
+ 600
+)
+target_allocator(ydb-core-tx-schemeshard-ut_serverless_reboots
+ system_allocator
+)
+vcs_info(ydb-core-tx-schemeshard-ut_serverless_reboots)
diff --git a/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.linux-aarch64.txt b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.linux-aarch64.txt
new file mode 100644
index 0000000000..36858a5a8a
--- /dev/null
+++ b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,87 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-core-tx-schemeshard-ut_serverless_reboots)
+target_compile_options(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_include_directories(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/schemeshard
+)
+target_link_libraries(ydb-core-tx-schemeshard-ut_serverless_reboots PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ cpp-testing-unittest_main
+ core-tx-schemeshard
+ library-cpp-getopt
+ cpp-regex-pcre
+ library-cpp-svnversion
+ core-testlib-default
+ ydb-core-tx
+ tx-schemeshard-ut_helpers
+ ydb-core-yql_testlib
+)
+target_link_options(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ -ldl
+ -lrt
+ -Wl,--no-as-needed
+ -fPIC
+ -fPIC
+ -lpthread
+ -lrt
+ -ldl
+)
+target_sources(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/schemeshard/ut_serverless_reboots/ut_serverless_reboots.cpp
+)
+set_property(
+ TARGET
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ SPLIT_FACTOR
+ 10
+)
+add_yunittest(
+ NAME
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ TEST_TARGET
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ PROCESSORS
+ 1
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ TIMEOUT
+ 600
+)
+target_allocator(ydb-core-tx-schemeshard-ut_serverless_reboots
+ cpp-malloc-jemalloc
+)
+vcs_info(ydb-core-tx-schemeshard-ut_serverless_reboots)
diff --git a/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.linux-x86_64.txt b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.linux-x86_64.txt
new file mode 100644
index 0000000000..cfaa780864
--- /dev/null
+++ b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.linux-x86_64.txt
@@ -0,0 +1,89 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-core-tx-schemeshard-ut_serverless_reboots)
+target_compile_options(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_include_directories(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/schemeshard
+)
+target_link_libraries(ydb-core-tx-schemeshard-ut_serverless_reboots PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-unittest_main
+ core-tx-schemeshard
+ library-cpp-getopt
+ cpp-regex-pcre
+ library-cpp-svnversion
+ core-testlib-default
+ ydb-core-tx
+ tx-schemeshard-ut_helpers
+ ydb-core-yql_testlib
+)
+target_link_options(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ -ldl
+ -lrt
+ -Wl,--no-as-needed
+ -fPIC
+ -fPIC
+ -lpthread
+ -lrt
+ -ldl
+)
+target_sources(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/schemeshard/ut_serverless_reboots/ut_serverless_reboots.cpp
+)
+set_property(
+ TARGET
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ SPLIT_FACTOR
+ 10
+)
+add_yunittest(
+ NAME
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ TEST_TARGET
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ PROCESSORS
+ 1
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ TIMEOUT
+ 600
+)
+target_allocator(ydb-core-tx-schemeshard-ut_serverless_reboots
+ cpp-malloc-tcmalloc
+ libs-tcmalloc-no_percpu_cache
+)
+vcs_info(ydb-core-tx-schemeshard-ut_serverless_reboots)
diff --git a/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.txt b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.txt
new file mode 100644
index 0000000000..2dce3a77fe
--- /dev/null
+++ b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.txt
@@ -0,0 +1,19 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ include(CMakeLists.darwin-x86_64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
+ include(CMakeLists.darwin-arm64.txt)
+elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
+ include(CMakeLists.windows-x86_64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-x86_64.txt)
+endif()
diff --git a/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.windows-x86_64.txt b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.windows-x86_64.txt
new file mode 100644
index 0000000000..9836cd321f
--- /dev/null
+++ b/ydb/core/tx/schemeshard/ut_serverless_reboots/CMakeLists.windows-x86_64.txt
@@ -0,0 +1,77 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-core-tx-schemeshard-ut_serverless_reboots)
+target_compile_options(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_include_directories(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/schemeshard
+)
+target_link_libraries(ydb-core-tx-schemeshard-ut_serverless_reboots PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-unittest_main
+ core-tx-schemeshard
+ library-cpp-getopt
+ cpp-regex-pcre
+ library-cpp-svnversion
+ core-testlib-default
+ ydb-core-tx
+ tx-schemeshard-ut_helpers
+ ydb-core-yql_testlib
+)
+target_sources(ydb-core-tx-schemeshard-ut_serverless_reboots PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/schemeshard/ut_serverless_reboots/ut_serverless_reboots.cpp
+)
+set_property(
+ TARGET
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ SPLIT_FACTOR
+ 10
+)
+add_yunittest(
+ NAME
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ TEST_TARGET
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ PROCESSORS
+ 1
+)
+set_yunittest_property(
+ TEST
+ ydb-core-tx-schemeshard-ut_serverless_reboots
+ PROPERTY
+ TIMEOUT
+ 600
+)
+target_allocator(ydb-core-tx-schemeshard-ut_serverless_reboots
+ system_allocator
+)
+vcs_info(ydb-core-tx-schemeshard-ut_serverless_reboots)
diff --git a/ydb/core/tx/schemeshard/ut_serverless_reboots/ut_serverless_reboots.cpp b/ydb/core/tx/schemeshard/ut_serverless_reboots/ut_serverless_reboots.cpp
new file mode 100644
index 0000000000..f02e90bb1e
--- /dev/null
+++ b/ydb/core/tx/schemeshard/ut_serverless_reboots/ut_serverless_reboots.cpp
@@ -0,0 +1,150 @@
+#include <ydb/core/tx/schemeshard/ut_helpers/helpers.h>
+
+using namespace NKikimr;
+using namespace NSchemeShard;
+using namespace NSchemeShardUT_Private;
+
+using enum NKikimrSubDomains::EServerlessComputeResourcesMode;
+
+Y_UNIT_TEST_SUITE(TSchemeShardServerLessReboots) {
+
+ using TCheckFunction = std::function<bool (const NKikimrScheme::TEvDescribeSchemeResult&)>;
+
+ void TestTenantSchemeShardSync(const TTestWithReboots& t, TTestActorRuntime& runtime, ui64 tenantSchemeShard,
+ const TString& path, TCheckFunction checkFunction) {
+ bool checkPassed = false;
+ for (size_t i = 0; i < 100; ++i) {
+ const auto describeResult = DescribePath(runtime, tenantSchemeShard, path);
+ if (checkFunction(describeResult)) {
+ checkPassed = true;
+ break;
+ }
+ t.TestEnv->SimulateSleep(runtime, TDuration::MilliSeconds(10));
+ }
+ UNIT_ASSERT(checkPassed);
+ }
+
+ TCheckFunction ServerlessComputeResourcesMode(EServerlessComputeResourcesMode serverlessComputeResourcesMode) {
+ return [=] (const NKikimrScheme::TEvDescribeSchemeResult& describeResult) {
+ if (describeResult.GetStatus() != NKikimrScheme::EStatus::StatusSuccess) {
+ return false;
+ }
+ const auto& domainDesc = describeResult.GetPathDescription().GetDomainDescription();
+ if (serverlessComputeResourcesMode) {
+ return domainDesc.GetServerlessComputeResourcesMode() == serverlessComputeResourcesMode;
+ } else {
+ return !domainDesc.HasServerlessComputeResourcesMode();
+ }
+ };
+ }
+
+ Y_UNIT_TEST(TestServerlessComputeResourcesModeWithReboots) {
+ TTestWithReboots t;
+ t.Run([&](TTestActorRuntime& runtime, bool& activeZone) {
+ {
+ TInactiveZone inactive(activeZone);
+ TestCreateExtSubDomain(runtime, ++t.TxId, "/MyRoot",
+ R"(Name: "SharedDB")"
+ );
+ t.TestEnv->TestWaitNotification(runtime, t.TxId);
+
+ TestAlterExtSubDomain(runtime, ++t.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"
+ )"
+ );
+ t.TestEnv->TestWaitNotification(runtime, t.TxId);
+
+ TString createData = Sprintf(
+ R"(
+ ResourcesDomainKey {
+ SchemeShard: %lu
+ PathId: 3
+ }
+ Name: "ServerLess0"
+ )",
+ TTestTxConfig::SchemeShard
+ );
+ TestCreateExtSubDomain(runtime, ++t.TxId, "/MyRoot", createData);
+ t.TestEnv->TestWaitNotification(runtime, t.TxId);
+
+ TestAlterExtSubDomain(runtime, ++t.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"
+ )"
+ );
+ t.TestEnv->TestWaitNotification(runtime, t.TxId);
+
+ ui64 tenantSchemeShard = 0;
+ TestDescribeResult(DescribePath(runtime, "/MyRoot/ServerLess0"),
+ {NLs::PathExist,
+ NLs::IsExternalSubDomain("ServerLess0"),
+ NLs::ServerlessComputeResourcesMode(SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED),
+ NLs::ExtractTenantSchemeshard(&tenantSchemeShard)});
+ TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/ServerLess0"),
+ {NLs::PathExist,
+ NLs::ServerlessComputeResourcesMode(SERVERLESS_COMPUTE_RESOURCES_MODE_UNSPECIFIED)});
+ }
+
+ TestAlterExtSubDomain(runtime, ++t.TxId, "/MyRoot",
+ R"(
+ ServerlessComputeResourcesMode: SERVERLESS_COMPUTE_RESOURCES_MODE_DEDICATED
+ Name: "ServerLess0"
+ )"
+ );
+ t.TestEnv->TestWaitNotification(runtime, t.TxId);
+
+ {
+ TInactiveZone inactive(activeZone);
+ ui64 tenantSchemeShard = 0;
+ TestDescribeResult(DescribePath(runtime, "/MyRoot/ServerLess0"),
+ {NLs::ServerlessComputeResourcesMode(SERVERLESS_COMPUTE_RESOURCES_MODE_DEDICATED),
+ NLs::ExtractTenantSchemeshard(&tenantSchemeShard)});
+ TestTenantSchemeShardSync(t, runtime, tenantSchemeShard, "/MyRoot/ServerLess0",
+ ServerlessComputeResourcesMode(SERVERLESS_COMPUTE_RESOURCES_MODE_DEDICATED));
+ }
+
+ TestAlterExtSubDomain(runtime, ++t.TxId, "/MyRoot",
+ R"(
+ ServerlessComputeResourcesMode: SERVERLESS_COMPUTE_RESOURCES_MODE_SHARED
+ Name: "ServerLess0"
+ )"
+ );
+ t.TestEnv->TestWaitNotification(runtime, t.TxId);
+
+ {
+ TInactiveZone inactive(activeZone);
+ ui64 tenantSchemeShard = 0;
+ TestDescribeResult(DescribePath(runtime, "/MyRoot/ServerLess0"),
+ {NLs::ServerlessComputeResourcesMode(SERVERLESS_COMPUTE_RESOURCES_MODE_SHARED),
+ NLs::ExtractTenantSchemeshard(&tenantSchemeShard)});
+ TestTenantSchemeShardSync(t, runtime, tenantSchemeShard, "/MyRoot/ServerLess0",
+ ServerlessComputeResourcesMode(SERVERLESS_COMPUTE_RESOURCES_MODE_SHARED));
+ }
+ });
+ }
+}
diff --git a/ydb/core/tx/schemeshard/ut_serverless_reboots/ya.make b/ydb/core/tx/schemeshard/ut_serverless_reboots/ya.make
new file mode 100644
index 0000000000..a08177a1da
--- /dev/null
+++ b/ydb/core/tx/schemeshard/ut_serverless_reboots/ya.make
@@ -0,0 +1,30 @@
+UNITTEST_FOR(ydb/core/tx/schemeshard)
+
+FORK_SUBTESTS()
+
+IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND)
+ TIMEOUT(3600)
+ SIZE(LARGE)
+ TAG(ya:fat)
+ELSE()
+ TIMEOUT(600)
+ SIZE(MEDIUM)
+ENDIF()
+
+PEERDIR(
+ library/cpp/getopt
+ library/cpp/regex/pcre
+ library/cpp/svnversion
+ ydb/core/testlib/default
+ ydb/core/tx
+ ydb/core/tx/schemeshard/ut_helpers
+ ydb/core/yql_testlib
+)
+
+YQL_LAST_ABI_VERSION()
+
+SRCS(
+ ut_serverless_reboots.cpp
+)
+
+END()
diff --git a/ydb/core/tx/schemeshard/ya.make b/ydb/core/tx/schemeshard/ya.make
index 1240b5ce21..483fe6ae36 100644
--- a/ydb/core/tx/schemeshard/ya.make
+++ b/ydb/core/tx/schemeshard/ya.make
@@ -37,6 +37,7 @@ RECURSE_FOR_TESTS(
ut_sequence
ut_sequence_reboots
ut_serverless
+ ut_serverless_reboots
ut_split_merge
ut_split_merge_reboots
ut_stats
diff --git a/ydb/tests/functional/scheme_tests/canondata/tablet_scheme_tests.TestTabletSchemes.test_tablet_schemes_flat_schemeshard_/flat_schemeshard.schema b/ydb/tests/functional/scheme_tests/canondata/tablet_scheme_tests.TestTabletSchemes.test_tablet_schemes_flat_schemeshard_/flat_schemeshard.schema
index 94b09951bf..2930c90e30 100644
--- a/ydb/tests/functional/scheme_tests/canondata/tablet_scheme_tests.TestTabletSchemes.test_tablet_schemes_flat_schemeshard_/flat_schemeshard.schema
+++ b/ydb/tests/functional/scheme_tests/canondata/tablet_scheme_tests.TestTabletSchemes.test_tablet_schemes_flat_schemeshard_/flat_schemeshard.schema
@@ -1413,6 +1413,11 @@
"ColumnId": 30,
"ColumnName": "AuditSettings",
"ColumnType": "String"
+ },
+ {
+ "ColumnId": 31,
+ "ColumnName": "ServerlessComputeResourcesMode",
+ "ColumnType": "Uint32"
}
],
"ColumnsDropped": [],
@@ -1448,7 +1453,8 @@
27,
28,
29,
- 30
+ 30,
+ 31
],
"RoomID": 0,
"Codec": 0,
@@ -2164,6 +2170,11 @@
"ColumnId": 10,
"ColumnName": "AuditSettings",
"ColumnType": "String"
+ },
+ {
+ "ColumnId": 11,
+ "ColumnName": "ServerlessComputeResourcesMode",
+ "ColumnType": "Uint32"
}
],
"ColumnsDropped": [],
@@ -2179,7 +2190,8 @@
7,
8,
9,
- 10
+ 10,
+ 11
],
"RoomID": 0,
"Codec": 0,