diff options
author | tesseract <tesseract@yandex-team.com> | 2023-02-09 19:16:18 +0300 |
---|---|---|
committer | tesseract <tesseract@yandex-team.com> | 2023-02-09 19:16:18 +0300 |
commit | abc4875e357da7c917051f7fce5138900938bbfa (patch) | |
tree | 12c4053436d6e2831b55f3d4ce34b1393ca08d8d | |
parent | 35cd948851fe388794d14b82f751006a3c271abc (diff) | |
download | ydb-abc4875e357da7c917051f7fce5138900938bbfa.tar.gz |
Починить ошибку вычисления зарезервированного места для топика
+ учитываем кол-во партиции при вычислении зарезервированного места топиком
+ унифицирован расчет: всегда берем кол-во партиции, и не используем кол-во групп
-rw-r--r-- | ydb/core/protos/subdomains.proto | 6 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard__init.cpp | 12 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp | 18 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp | 29 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp | 18 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard__operation_deallocate_pq.cpp | 16 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp | 15 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard_path_describer.cpp | 1 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard_utils.cpp | 19 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard_utils.h | 8 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_base.cpp | 222 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp | 15 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_helpers/ls_checks.h | 1 |
13 files changed, 304 insertions, 76 deletions
diff --git a/ydb/core/protos/subdomains.proto b/ydb/core/protos/subdomains.proto index 5d665ff381..4ac4a22cb5 100644 --- a/ydb/core/protos/subdomains.proto +++ b/ydb/core/protos/subdomains.proto @@ -46,7 +46,13 @@ message TDiskSpaceUsage { optional uint64 IndexSize = 3; } + message TTopics { + // in bytes + optional uint64 ReserveSize = 1; + } + optional TTables Tables = 1; + optional TTopics Topics = 2; } message TDomainState { diff --git a/ydb/core/tx/schemeshard/schemeshard__init.cpp b/ydb/core/tx/schemeshard/schemeshard__init.cpp index 228cf257e4..78524389b7 100644 --- a/ydb/core/tx/schemeshard/schemeshard__init.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__init.cpp @@ -3,6 +3,7 @@ #include <ydb/core/scheme/scheme_types_proto.h> #include <ydb/core/tablet/tablet_exception.h> #include <ydb/core/tablet_flat/flat_cxx_database.h> +#include <ydb/core/tx/schemeshard/schemeshard_utils.h> #include <ydb/core/util/pb.h> namespace NKikimr { @@ -3930,7 +3931,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { if (path->IsPQGroup()) { auto pqGroup = Self->PersQueueGroups.at(path->PathId); - auto delta = pqGroup->AlterData ? pqGroup->AlterData->TotalGroupCount : pqGroup->TotalGroupCount; + auto delta = pqGroup->AlterData ? pqGroup->AlterData->TotalPartitionCount : pqGroup->TotalPartitionCount; auto tabletConfig = pqGroup->AlterData ? (pqGroup->AlterData->TabletConfig.empty() ? pqGroup->TabletConfig : pqGroup->AlterData->TabletConfig) : pqGroup->TabletConfig; NKikimrPQ::TPQTabletConfig config; @@ -3938,15 +3939,14 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { bool parseOk = ParseFromStringNoSizeLimit(config, tabletConfig); Y_VERIFY(parseOk); - ui64 throughput = ((ui64)delta) * config.GetPartitionConfig().GetWriteSpeedInBytesPerSecond(); - ui64 storage = throughput * config.GetPartitionConfig().GetLifetimeSeconds(); + const PQGroupReserve reserve(config, delta); inclusiveDomainInfo->IncPQPartitionsInside(delta); - inclusiveDomainInfo->IncPQReservedStorage(storage); + inclusiveDomainInfo->IncPQReservedStorage(reserve.Storage); Self->TabletCounters->Simple()[COUNTER_STREAM_SHARDS_COUNT].Add(delta); - Self->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Add(throughput); - Self->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Add(storage); + Self->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Add(reserve.Throughput); + Self->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Add(reserve.Storage); } if (path->PlannedToDrop()) { diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp index 31265149ae..26636e2aeb 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp @@ -262,15 +262,7 @@ public: const ui64 shardsToCreate = pqGroupInfo->ExpectedShardCount() + 1; const ui64 partitionsToCreate = pqGroupInfo->TotalPartitionCount; - const ui64 throughput = ((ui64)partitionsToCreate) * - tabletConfig.GetPartitionConfig().GetWriteSpeedInBytesPerSecond(); - - ui64 storage = 0; - if (tabletConfig.GetPartitionConfig().HasStorageLimitBytes()) { - storage = tabletConfig.GetPartitionConfig().GetStorageLimitBytes(); - } else { - storage = throughput * tabletConfig.GetPartitionConfig().GetLifetimeSeconds(); - } + const PQGroupReserve reserve(tabletConfig, partitionsToCreate); { NSchemeShard::TPath::TChecker checks = dstPath.Check(); @@ -278,7 +270,7 @@ public: .ShardsLimit(shardsToCreate) .PathShardsLimit(shardsToCreate) .PQPartitionsLimit(partitionsToCreate) - .PQReservedStorageLimit(storage); + .PQReservedStorageLimit(reserve.Storage); if (!checks) { result->SetError(checks.GetStatus(), checks.GetError()); @@ -465,12 +457,12 @@ public: dstPath.DomainInfo()->IncPathsInside(); dstPath.DomainInfo()->AddInternalShards(txState); dstPath.DomainInfo()->IncPQPartitionsInside(partitionsToCreate); - dstPath.DomainInfo()->IncPQReservedStorage(storage); + dstPath.DomainInfo()->IncPQReservedStorage(reserve.Storage); dstPath.Base()->IncShardsInside(shardsToCreate); parentPath.Base()->IncAliveChildren(); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Add(throughput); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Add(storage); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Add(reserve.Throughput); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Add(reserve.Storage); context.SS->TabletCounters->Simple()[COUNTER_STREAM_SHARDS_COUNT].Add(partitionsToCreate); SetState(NextState()); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp index 2c0180ac14..d5d272e2e7 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp @@ -519,23 +519,10 @@ public: return result; } - auto getStorageLimit = [](auto &config, ui64 throughput) { - if (config.GetPartitionConfig().HasStorageLimitBytes()) { - return config.GetPartitionConfig().GetStorageLimitBytes(); - } else { - return throughput * config.GetPartitionConfig().GetLifetimeSeconds(); - } - }; - - const ui64 throughput = ((ui64)(newTabletConfig.GetPartitionConfig().GetWriteSpeedInBytesPerSecond())) * - (alterData->TotalGroupCount); - const ui64 oldThroughput = ((ui64)(tabletConfig.GetPartitionConfig().GetWriteSpeedInBytesPerSecond())) * - (pqGroup->TotalGroupCount); - - const ui64 storage = getStorageLimit(newTabletConfig, throughput); - const ui64 oldStorage = getStorageLimit(tabletConfig, oldThroughput); + const PQGroupReserve reserve(newTabletConfig, alterData->TotalPartitionCount); + const PQGroupReserve oldReserve(tabletConfig, pqGroup->TotalPartitionCount); - const ui64 storageToReserve = storage > oldStorage ? storage - oldStorage : 0; + const ui64 storageToReserve = reserve.Storage > oldReserve.Storage ? reserve.Storage - oldReserve.Storage : 0; { TPath::TChecker checks = path.Check(); @@ -604,14 +591,14 @@ public: path.DomainInfo()->AddInternalShards(txState); path.DomainInfo()->IncPQPartitionsInside(partitionsToCreate); - path.DomainInfo()->UpdatePQReservedStorage(oldStorage, storage); + path.DomainInfo()->UpdatePQReservedStorage(oldReserve.Storage, reserve.Storage); path.Base()->IncShardsInside(shardsToCreate); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Add(throughput); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Sub(oldThroughput); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Add(reserve.Throughput); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Sub(oldReserve.Throughput); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Add(storage); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Sub(oldStorage); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Add(reserve.Storage); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Sub(oldReserve.Storage); context.SS->TabletCounters->Simple()[COUNTER_STREAM_SHARDS_COUNT].Add(partitionsToCreate); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp index 4f08d93fac..7edabf405f 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp @@ -365,15 +365,7 @@ public: bool parseOk = ParseFromStringNoSizeLimit(config, tabletConfig); Y_VERIFY(parseOk); - const ui64 throughput = ((ui64)partitionsToCreate) * - config.GetPartitionConfig().GetWriteSpeedInBytesPerSecond(); - const ui64 storage = [&config, &throughput]() { - if (config.GetPartitionConfig().HasStorageLimitBytes()) { - return config.GetPartitionConfig().GetStorageLimitBytes(); - } else { - return throughput * config.GetPartitionConfig().GetLifetimeSeconds(); - } - }(); + const PQGroupReserve reserve(config, partitionsToCreate); { NSchemeShard::TPath::TChecker checks = dstPath.Check(); @@ -381,7 +373,7 @@ public: .ShardsLimit(shardsToCreate) .PathShardsLimit(shardsToCreate) .PQPartitionsLimit(partitionsToCreate) - .PQReservedStorageLimit(storage); + .PQReservedStorageLimit(reserve.Storage); if (!checks) { result->SetError(checks.GetStatus(), checks.GetError()); @@ -515,10 +507,10 @@ public: dstPath.DomainInfo()->IncPathsInside(); dstPath.DomainInfo()->AddInternalShards(txState); dstPath.DomainInfo()->IncPQPartitionsInside(partitionsToCreate); - dstPath.DomainInfo()->IncPQReservedStorage(storage); + dstPath.DomainInfo()->IncPQReservedStorage(reserve.Storage); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Add(throughput); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Add(storage); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Add(reserve.Throughput); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Add(reserve.Storage); context.SS->TabletCounters->Simple()[COUNTER_STREAM_SHARDS_COUNT].Add(partitionsToCreate); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_deallocate_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_deallocate_pq.cpp index a5bc8b34ce..324cf07429 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_deallocate_pq.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_deallocate_pq.cpp @@ -111,23 +111,15 @@ public: bool parseOk = ParseFromStringNoSizeLimit(config, tabletConfig); Y_VERIFY(parseOk); - ui64 throughput = ((ui64)pqGroup->TotalPartitionCount) * config.GetPartitionConfig().GetWriteSpeedInBytesPerSecond(); + const PQGroupReserve reserve(config, pqGroup->TotalPartitionCount); - const ui64 storage = [&config, &throughput]() { - if (config.GetPartitionConfig().HasStorageLimitBytes()) { - return config.GetPartitionConfig().GetStorageLimitBytes(); - } else { - return throughput * config.GetPartitionConfig().GetLifetimeSeconds(); - } - }(); - auto domainInfo = context.SS->ResolveDomainInfo(pathId); domainInfo->DecPathsInside(); domainInfo->DecPQPartitionsInside(pqGroup->TotalPartitionCount); - domainInfo->DecPQReservedStorage(storage); + domainInfo->DecPQReservedStorage(reserve.Storage); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Sub(throughput); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Sub(storage); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Sub(reserve.Throughput); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Sub(reserve.Storage); context.SS->TabletCounters->Simple()[COUNTER_STREAM_SHARDS_COUNT].Sub(pqGroup->TotalPartitionCount); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp index e7b445d445..e9fc5ee99a 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp @@ -211,22 +211,15 @@ public: bool parseOk = ParseFromStringNoSizeLimit(config, tabletConfig); Y_VERIFY(parseOk); - ui64 throughput = ((ui64)pqGroup->TotalPartitionCount) * config.GetPartitionConfig().GetWriteSpeedInBytesPerSecond(); - const ui64 storage = [&config, &throughput]() { - if (config.GetPartitionConfig().HasStorageLimitBytes()) { - return config.GetPartitionConfig().GetStorageLimitBytes(); - } else { - return throughput * config.GetPartitionConfig().GetLifetimeSeconds(); - } - }(); + const PQGroupReserve reserve(config, pqGroup->TotalPartitionCount); auto domainInfo = context.SS->ResolveDomainInfo(pathId); domainInfo->DecPathsInside(); domainInfo->DecPQPartitionsInside(pqGroup->TotalPartitionCount); - domainInfo->DecPQReservedStorage(storage); + domainInfo->DecPQReservedStorage(reserve.Storage); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Sub(throughput); - context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Sub(storage); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Sub(reserve.Throughput); + context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Sub(reserve.Storage); context.SS->TabletCounters->Simple()[COUNTER_STREAM_SHARDS_COUNT].Sub(pqGroup->TotalPartitionCount); diff --git a/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp b/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp index 538580049f..bb04164791 100644 --- a/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp @@ -673,6 +673,7 @@ void TPathDescriber::DescribeDomainRoot(TPathElement::TPtr pathEl) { diskSpaceUsage->MutableTables()->SetTotalSize(subDomainInfo->GetDiskSpaceUsage().Tables.TotalSize); diskSpaceUsage->MutableTables()->SetDataSize(subDomainInfo->GetDiskSpaceUsage().Tables.DataSize); diskSpaceUsage->MutableTables()->SetIndexSize(subDomainInfo->GetDiskSpaceUsage().Tables.IndexSize); + diskSpaceUsage->MutableTopics()->SetReserveSize(subDomainInfo->GetPQReservedStorage()); if (subDomainInfo->GetDeclaredSchemeQuotas()) { entry->MutableDeclaredSchemeQuotas()->CopyFrom(*subDomainInfo->GetDeclaredSchemeQuotas()); diff --git a/ydb/core/tx/schemeshard/schemeshard_utils.cpp b/ydb/core/tx/schemeshard/schemeshard_utils.cpp index 56ba5d161d..23241b143a 100644 --- a/ydb/core/tx/schemeshard/schemeshard_utils.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_utils.cpp @@ -199,6 +199,25 @@ void TSelfPinger::ScheduleSelfPingWakeup(const NActors::TActorContext &ctx) { SelfPingWakeupScheduledTime = AppData(ctx)->TimeProvider->Now(); } +PQGroupReserve::PQGroupReserve(const ::NKikimrPQ::TPQTabletConfig& tabletConfig, ui64 partitions) { + const auto& partitionConfig = tabletConfig.GetPartitionConfig(); + + if (tabletConfig.GetMeteringMode() == NKikimrPQ::TPQTabletConfig::METERING_MODE_RESERVED_CAPACITY) { + const ui64 throughput = partitions * partitionConfig.GetWriteSpeedInBytesPerSecond(); + + Throughput = throughput; + + if (partitionConfig.HasStorageLimitBytes()) { + Storage = partitions * partitionConfig.GetStorageLimitBytes(); + } else { + Storage = throughput * partitionConfig.GetLifetimeSeconds(); + } + } else { + Throughput = 0; + Storage = 0; + } +} + } namespace NTableIndex { diff --git a/ydb/core/tx/schemeshard/schemeshard_utils.h b/ydb/core/tx/schemeshard/schemeshard_utils.h index 4bdba6701e..5f75482c88 100644 --- a/ydb/core/tx/schemeshard/schemeshard_utils.h +++ b/ydb/core/tx/schemeshard/schemeshard_utils.h @@ -123,6 +123,14 @@ private: bool SelfPingWakeupScheduled; }; +class PQGroupReserve { +public: + PQGroupReserve(const ::NKikimrPQ::TPQTabletConfig& tabletConfig, ui64 partitions); + + ui64 Storage; + ui64 Throughput; +}; + } // NSchemeShard namespace NTableIndex { diff --git a/ydb/core/tx/schemeshard/ut_base.cpp b/ydb/core/tx/schemeshard/ut_base.cpp index 9989f500c9..569685595a 100644 --- a/ydb/core/tx/schemeshard/ut_base.cpp +++ b/ydb/core/tx/schemeshard/ut_base.cpp @@ -10549,4 +10549,226 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { } ); } + + Y_UNIT_TEST(TopicMeteringModeAndStorageSize) { + TTestBasicRuntime runtime; + TTestEnv env(runtime); + ui64 txId = 100; + + const auto AssertReserve = [&] (TString path, ui64 expectedReservedStorage) { + TestDescribeResult(DescribePath(runtime, path), + {NLs::Finished, + NLs::PQReservedStorage(expectedReservedStorage)}); + }; + + // create with WriteSpeedInBytesPerSecond + TestCreatePQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + TotalGroupCount: 1 + PartitionPerTablet: 1 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + WriteSpeedInBytesPerSecond : 19 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 1 * 13 * 19); + + // Change MeteringMode + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + WriteSpeedInBytesPerSecond : 19 + } + MeteringMode: METERING_MODE_REQUEST_UNITS + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 0); + + // Change MeteringMode + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + WriteSpeedInBytesPerSecond : 19 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 1 * 13 * 19); + + // increase partitions count + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + TotalGroupCount: 7 + PartitionPerTablet: 7 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + WriteSpeedInBytesPerSecond : 19 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 7 * 13 * 19); + + // increase WriteSpeedInBytesPerSecond + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + TotalGroupCount: 7 + PartitionPerTablet: 7 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + WriteSpeedInBytesPerSecond : 23 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 7 * 13 * 23); + + // decrease WriteSpeedInBytesPerSecond + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + TotalGroupCount: 7 + PartitionPerTablet: 7 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + WriteSpeedInBytesPerSecond : 19 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 7 * 13 * 19); + + // increase LifetimeSeconds + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + TotalGroupCount: 7 + PartitionPerTablet: 7 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 17 + WriteSpeedInBytesPerSecond : 23 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 7 * 17 * 23); + + // decrease LifetimeSeconds + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + TotalGroupCount: 7 + PartitionPerTablet: 7 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + WriteSpeedInBytesPerSecond : 19 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 7 * 13 * 19); + + // use StorageLimitBytes + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + TotalGroupCount: 7 + PartitionPerTablet: 7 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + StorageLimitBytes : 17 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 7 * 17); + + // increase StorageLimitBytes + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + TotalGroupCount: 7 + PartitionPerTablet: 7 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + StorageLimitBytes : 23 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 7 * 23); + + // decrease StorageLimitBytes + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + TotalGroupCount: 7 + PartitionPerTablet: 7 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + StorageLimitBytes : 17 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 7 * 17); + + // increase partitions count + TestAlterPQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic1" + TotalGroupCount: 11 + PartitionPerTablet: 11 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + StorageLimitBytes : 17 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic1", 11 * 17); + + // drop partiotion + TestDropPQGroup(runtime, ++txId, "/MyRoot", "Topic1"); + env.TestWaitNotification(runtime, txId); + + + // create with StorageLimitBytes + TestCreatePQGroup(runtime, ++txId, "/MyRoot", R"( + Name: "Topic2" + TotalGroupCount: 3 + PartitionPerTablet: 3 + PQTabletConfig { + PartitionConfig { + LifetimeSeconds: 13 + StorageLimitBytes : 17 + } + MeteringMode: METERING_MODE_RESERVED_CAPACITY + } + )"); + env.TestWaitNotification(runtime, txId); + AssertReserve("/MyRoot/Topic2", 3 * 17); + } + } diff --git a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp index ebde6a638a..a47cebcf4a 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp +++ b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp @@ -611,6 +611,21 @@ TCheckFunc PQPartitionsInsideDomain(ui64 count) { }; } +TCheckFunc PQReservedStorage(ui64 count) { + return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) { + UNIT_ASSERT_C(IsGoodDomainStatus(record.GetStatus()), "Unexpected status: " << record.GetStatus()); + + const auto& pathDescr = record.GetPathDescription(); + const auto& domain = pathDescr.GetDomainDescription(); + const auto& curCount = domain.GetDiskSpaceUsage().GetTopics().GetReserveSize(); + + UNIT_ASSERT_EQUAL_C(curCount, count, + "pq reserved storage mismatch, domain with id " << domain.GetDomainKey().GetPathId() << + " has size " << curCount << + " but expected " << count); + }; +} + TCheckFunc PathsInsideDomainOneOf(TSet<ui64> variants) { return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) { UNIT_ASSERT_C(IsGoodDomainStatus(record.GetStatus()), "Unexpected status: " << record.GetStatus()); diff --git a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h index 0a4a266a1e..e21efb9d90 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h +++ b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h @@ -34,6 +34,7 @@ namespace NLs { TCheckFunc PathsInsideDomain(ui64 count); TCheckFunc PQPartitionsInsideDomain(ui64 count); + TCheckFunc PQReservedStorage(ui64 count); TCheckFunc PathsInsideDomainOneOf(TSet<ui64> variants); TCheckFunc ShardsInsideDomain(ui64 count); TCheckFunc ShardsInsideDomainOneOf(TSet<ui64> variants); |