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
13 changes: 7 additions & 6 deletions ydb/core/cms/console/console__create_tenant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,20 @@ class TTenantsManager::TTxCreateTenant : public TTransactionBase<TTenantsManager
return Error(Ydb::StatusIds::BAD_REQUEST,
TStringBuilder() << "Overall data size soft quota (" << softQuota << ")"
<< " of the database " << path
<< " must be smaller than the hard quota (" << hardQuota << ")",
<< " must be less than or equal to the hard quota (" << hardQuota << ")",
ctx
);
}
for (const auto& storageQuota : quotas.storage_quotas()) {
const auto unitHardQuota = storageQuota.data_size_hard_quota();
const auto unitSoftQuota = storageQuota.data_size_soft_quota();
for (const auto& storageUnitQuota : quotas.storage_quotas()) {
const auto unitHardQuota = storageUnitQuota.data_size_hard_quota();
const auto unitSoftQuota = storageUnitQuota.data_size_soft_quota();
if (unitHardQuota && unitSoftQuota && unitHardQuota < unitSoftQuota) {
return Error(Ydb::StatusIds::BAD_REQUEST,
TStringBuilder() << "Data size soft quota (" << unitSoftQuota << ")"
<< " for a " << storageQuota.unit_kind() << " storage unit "
<< " for a " << storageUnitQuota.unit_kind() << " storage unit "
<< " of the database " << path
<< " must be smaller than the corresponding hard quota (" << unitHardQuota << ")",
<< " must be less than or equal to"
<< " the corresponding hard quota (" << unitHardQuota << ")",
ctx
);
}
Expand Down
7 changes: 7 additions & 0 deletions ydb/core/protos/counters_schemeshard.proto
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ enum ESimpleCounters {
COUNTER_IN_FLIGHT_OPS_TxCreateContinuousBackup = 162 [(CounterOpts) = {Name: "InFlightOps/CreateContinuousBackup"}];
COUNTER_IN_FLIGHT_OPS_TxAlterContinuousBackup = 163 [(CounterOpts) = {Name: "InFlightOps/AlterContinuousBackup"}];
COUNTER_IN_FLIGHT_OPS_TxDropContinuousBackup = 164 [(CounterOpts) = {Name: "InFlightOps/DropContinuousBackup"}];

COUNTER_DISK_SPACE_TABLES_DATA_BYTES_ON_SSD = 165 [(CounterOpts) = {Name: "DiskSpaceTablesDataBytesOnSsd"}];
COUNTER_DISK_SPACE_TABLES_INDEX_BYTES_ON_SSD = 166 [(CounterOpts) = {Name: "DiskSpaceTablesIndexBytesOnSsd"}];
COUNTER_DISK_SPACE_TABLES_TOTAL_BYTES_ON_SSD = 167 [(CounterOpts) = {Name: "DiskSpaceTablesTotalBytesOnSsd"}];
COUNTER_DISK_SPACE_TABLES_DATA_BYTES_ON_HDD = 168 [(CounterOpts) = {Name: "DiskSpaceTablesDataBytesOnHdd"}];
COUNTER_DISK_SPACE_TABLES_INDEX_BYTES_ON_HDD = 169 [(CounterOpts) = {Name: "DiskSpaceTablesIndexBytesOnHdd"}];
COUNTER_DISK_SPACE_TABLES_TOTAL_BYTES_ON_HDD = 170 [(CounterOpts) = {Name: "DiskSpaceTablesTotalBytesOnHdd"}];
}

enum ECumulativeCounters {
Expand Down
12 changes: 12 additions & 0 deletions ydb/core/sys_view/service/ext_counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class TExtCountersUpdaterActor
TCounterPtr MemoryUsedBytes;
TCounterPtr MemoryLimitBytes;
TCounterPtr StorageUsedBytes;
TCounterPtr StorageUsedBytesOnSsd;
TCounterPtr StorageUsedBytesOnHdd;
TVector<TCounterPtr> CpuUsedCorePercents;
TVector<TCounterPtr> CpuLimitCorePercents;
THistogramPtr ExecuteLatencyMs;
Expand Down Expand Up @@ -54,6 +56,10 @@ class TExtCountersUpdaterActor
"resources.memory.limit_bytes", false);
StorageUsedBytes = ydbGroup->GetNamedCounter("name",
"resources.storage.used_bytes", false);
StorageUsedBytesOnSsd = ydbGroup->GetNamedCounter("name",
"resources.storage.used_bytes.ssd", false);
StorageUsedBytesOnHdd = ydbGroup->GetNamedCounter("name",
"resources.storage.used_bytes.hdd", false);

auto poolCount = Config.Pools.size();
CpuUsedCorePercents.resize(poolCount);
Expand Down Expand Up @@ -110,6 +116,12 @@ class TExtCountersUpdaterActor
if (StorageUsedBytes->Val() != 0) {
metrics->AddMetric("resources.storage.used_bytes", StorageUsedBytes->Val());
}
if (StorageUsedBytesOnSsd->Val() != 0) {
metrics->AddMetric("resources.storage.used_bytes.ssd", StorageUsedBytesOnSsd->Val());
}
if (StorageUsedBytesOnHdd->Val() != 0) {
metrics->AddMetric("resources.storage.used_bytes.hdd", StorageUsedBytesOnHdd->Val());
}
if (!Config.Pools.empty()) {
double cpuUsage = 0;
for (size_t i = 0; i < Config.Pools.size(); ++i) {
Expand Down
22 changes: 22 additions & 0 deletions ydb/core/tablet/tablet_counters_aggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,12 @@ class TTabletMon {
TCounterPtr ColumnShardBulkUpsertRows_;
TCounterPtr ColumnShardBulkUpsertBytes_;
TCounterPtr ResourcesStorageUsedBytes;
TCounterPtr ResourcesStorageUsedBytesOnSsd;
TCounterPtr ResourcesStorageUsedBytesOnHdd;
TCounterPtr ResourcesStorageLimitBytes;
TCounterPtr ResourcesStorageTableUsedBytes;
TCounterPtr ResourcesStorageTableUsedBytesOnSsd;
TCounterPtr ResourcesStorageTableUsedBytesOnHdd;
TCounterPtr ResourcesStorageTopicUsedBytes;
TCounterPtr ResourcesStreamUsedShards;
TCounterPtr ResourcesStreamLimitShards;
Expand Down Expand Up @@ -806,6 +810,8 @@ class TTabletMon {
TCounterPtr ColumnShardUpsertBytesWritten_;

TCounterPtr DiskSpaceTablesTotalBytes;
TCounterPtr DiskSpaceTablesTotalBytesOnSsd;
TCounterPtr DiskSpaceTablesTotalBytesOnHdd;
TCounterPtr DiskSpaceTopicsTotalBytes;
TCounterPtr DiskSpaceSoftQuotaBytes;

Expand Down Expand Up @@ -860,10 +866,18 @@ class TTabletMon {

ResourcesStorageUsedBytes = ydbGroup->GetNamedCounter("name",
"resources.storage.used_bytes", false);
ResourcesStorageUsedBytesOnSsd = ydbGroup->GetNamedCounter("name",
"resources.storage.used_bytes.ssd", false);
ResourcesStorageUsedBytesOnHdd = ydbGroup->GetNamedCounter("name",
"resources.storage.used_bytes.hdd", false);
ResourcesStorageLimitBytes = ydbGroup->GetNamedCounter("name",
"resources.storage.limit_bytes", false);
ResourcesStorageTableUsedBytes = ydbGroup->GetNamedCounter("name",
"resources.storage.table.used_bytes", false);
ResourcesStorageTableUsedBytesOnSsd = ydbGroup->GetNamedCounter("name",
"resources.storage.table.used_bytes.ssd", false);
ResourcesStorageTableUsedBytesOnHdd = ydbGroup->GetNamedCounter("name",
"resources.storage.table.used_bytes.hdd", false);
ResourcesStorageTopicUsedBytes = ydbGroup->GetNamedCounter("name",
"resources.storage.topic.used_bytes", false);

Expand Down Expand Up @@ -930,6 +944,8 @@ class TTabletMon {
auto appGroup = schemeshardGroup->GetSubgroup("category", "app");

DiskSpaceTablesTotalBytes = appGroup->GetCounter("SUM(SchemeShard/DiskSpaceTablesTotalBytes)");
DiskSpaceTablesTotalBytesOnSsd = appGroup->GetCounter("SUM(SchemeShard/DiskSpaceTablesTotalBytesOnSsd)");
DiskSpaceTablesTotalBytesOnHdd = appGroup->GetCounter("SUM(SchemeShard/DiskSpaceTablesTotalBytesOnHdd)");
DiskSpaceTopicsTotalBytes = appGroup->GetCounter("SUM(SchemeShard/DiskSpaceTopicsTotalBytes)");
DiskSpaceSoftQuotaBytes = appGroup->GetCounter("SUM(SchemeShard/DiskSpaceSoftQuotaBytes)");

Expand Down Expand Up @@ -973,12 +989,18 @@ class TTabletMon {
if (DiskSpaceTablesTotalBytes) {
ResourcesStorageLimitBytes->Set(DiskSpaceSoftQuotaBytes->Val());
ResourcesStorageTableUsedBytes->Set(DiskSpaceTablesTotalBytes->Val());
ResourcesStorageTableUsedBytesOnSsd->Set(DiskSpaceTablesTotalBytesOnSsd->Val());
ResourcesStorageTableUsedBytesOnHdd->Set(DiskSpaceTablesTotalBytesOnHdd->Val());
ResourcesStorageTopicUsedBytes->Set(DiskSpaceTopicsTotalBytes->Val());

if (AppData()->FeatureFlags.GetEnableTopicDiskSubDomainQuota()) {
ResourcesStorageUsedBytes->Set(ResourcesStorageTableUsedBytes->Val() + ResourcesStorageTopicUsedBytes->Val());
ResourcesStorageUsedBytesOnSsd->Set(ResourcesStorageTableUsedBytesOnSsd->Val());
ResourcesStorageUsedBytesOnHdd->Set(ResourcesStorageTableUsedBytesOnHdd->Val());
} else {
ResourcesStorageUsedBytes->Set(ResourcesStorageTableUsedBytes->Val());
ResourcesStorageUsedBytesOnSsd->Set(ResourcesStorageTableUsedBytesOnSsd->Val());
ResourcesStorageUsedBytesOnHdd->Set(ResourcesStorageTableUsedBytesOnHdd->Val());
}

auto quota = StreamShardsQuota->Val();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ VerifyParams(TParamsDelta* delta, const TPathId pathId, const TSubDomainInfo::TP
if (const auto& effectivePools = requestedPools.empty()
? actualPools
: requestedPools;
!CheckStorageQuotasKinds(input.GetDatabaseQuotas(), effectivePools, pathId.ToString(), error)
!CheckStoragePoolsInQuotas(input.GetDatabaseQuotas(), effectivePools, input.GetName(), error)
) {
return paramError(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class TAlterSubDomain: public TSubOperation {
if (const auto& effectivePools = requestedPools.empty()
? actualPools
: requestedPools;
!CheckStorageQuotasKinds(settings.GetDatabaseQuotas(), effectivePools, path.PathString(), errStr)
!CheckStoragePoolsInQuotas(settings.GetDatabaseQuotas(), effectivePools, path.PathString(), errStr)
) {
result->SetError(NKikimrScheme::StatusInvalidParameter, errStr);
return result;
Expand Down
45 changes: 28 additions & 17 deletions ydb/core/tx/schemeshard/schemeshard__operation_common_subdomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,44 @@
namespace NKikimr {
namespace NSchemeShard {

inline bool CheckStorageQuotasKinds(const Ydb::Cms::DatabaseQuotas& quotas,
const TVector<TStoragePool>& pools,
const TString& path,
TString& error
inline bool CheckStoragePoolsInQuotas(
const Ydb::Cms::DatabaseQuotas& quotas,
const TVector<TStoragePool>& pools,
const TString& path,
TString& error
) {
TVector<TString> quotedKinds;
quotedKinds.reserve(quotas.storage_quotas_size());
for (const auto& storageQuota : quotas.storage_quotas()) {
quotedKinds.emplace_back(storageQuota.unit_kind());
}
Sort(quotedKinds);
const auto uniqueEnd = Unique(quotedKinds.begin(), quotedKinds.end());
if (uniqueEnd != quotedKinds.end()) {
if (const auto equalKinds = AdjacentFind(quotedKinds);
equalKinds != quotedKinds.end()
) {
error = TStringBuilder()
<< "Malformed subdomain request: storage quotas' unit kinds must be unique, but "
<< *uniqueEnd << " appears twice in the storage quotas definition of the " << path << " subdomain.";
<< "Malformed subdomain request: storage kinds in DatabaseQuotas must be unique, but "
<< *equalKinds << " appears twice in the quotas definition of the " << path << " subdomain.";
return false;
}

for (const auto& quotedKind : quotedKinds) {
if (!AnyOf(pools, [&quotedKind](const TStoragePool& pool) {
return pool.GetKind() == quotedKind;
})) {
error = TStringBuilder()
<< "Malformed subdomain request: cannot set a " << quotedKind << " storage quota, "
<< "because no storage pool in the subdomain " << path << " has the specified kind.";
return false;
}
TVector<TString> existingKinds;
existingKinds.reserve(pools.size());
for (const auto& pool : pools) {
existingKinds.emplace_back(pool.GetKind());
}
Sort(existingKinds);
TVector<TString> unknownKinds;
SetDifference(quotedKinds.begin(), quotedKinds.end(),
existingKinds.begin(), existingKinds.end(),
std::back_inserter(unknownKinds)
);
if (!unknownKinds.empty()) {
error = TStringBuilder()
<< "Malformed subdomain request: cannot set storage quotas of the following kinds: " << JoinSeq(", ", unknownKinds)
<< ", because no storage pool in the subdomain " << path << " has the specified kinds. "
<< "Existing storage kinds are: " << JoinSeq(", ", existingKinds);
return false;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class TCreateSubDomain: public TSubOperation {

if (settings.HasDatabaseQuotas()) {
if (!requestedStoragePools.empty()
&& !CheckStorageQuotasKinds(settings.GetDatabaseQuotas(), requestedStoragePools, dstPath.PathString(), errStr)
&& !CheckStoragePoolsInQuotas(settings.GetDatabaseQuotas(), requestedStoragePools, dstPath.PathString(), errStr)
) {
result->SetError(NKikimrScheme::StatusInvalidParameter, errStr);
return result;
Expand Down
4 changes: 2 additions & 2 deletions ydb/core/tx/schemeshard/schemeshard__table_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ TPartitionStats TTxStoreTableStats::PrepareStats(const TActorContext& ctx,
indexSize += channelStats.GetIndexSize();
} else {
LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
"PrepareStats: the subdomain has no info about the datashard's channel "
<< channelStats.GetChannel()
"PrepareStats: SchemeShard has no info on DataShard "
<< rec.GetDatashardId() << " channel " << channelStats.GetChannel() << " binding"
);
}
}
Expand Down
12 changes: 12 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7216,6 +7216,18 @@ void TSchemeShard::ChangeDiskSpaceTablesTotalBytes(i64 delta) {
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_TOTAL_BYTES].Add(delta);
}

void TSchemeShard::ChangeDiskSpaceTables(EUserFacingStorageType storageType, i64 dataDelta, i64 indexDelta) {
if (storageType == EUserFacingStorageType::Ssd) {
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_DATA_BYTES_ON_SSD].Add(dataDelta);
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_INDEX_BYTES_ON_SSD].Add(indexDelta);
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_TOTAL_BYTES_ON_SSD].Add(dataDelta + indexDelta);
} else if (storageType == EUserFacingStorageType::Hdd) {
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_DATA_BYTES_ON_HDD].Add(dataDelta);
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_INDEX_BYTES_ON_HDD].Add(indexDelta);
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_TOTAL_BYTES_ON_HDD].Add(dataDelta + indexDelta);
}
}

void TSchemeShard::ChangeDiskSpaceTopicsTotalBytes(ui64 value) {
TabletCounters->Simple()[COUNTER_DISK_SPACE_TOPICS_TOTAL_BYTES].Set(value);
}
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 @@ -1380,6 +1380,7 @@ class TSchemeShard
void ChangeDiskSpaceTablesDataBytes(i64 delta) override;
void ChangeDiskSpaceTablesIndexBytes(i64 delta) override;
void ChangeDiskSpaceTablesTotalBytes(i64 delta) override;
void ChangeDiskSpaceTables(EUserFacingStorageType storageType, i64 dataDelta, i64 indexDelta) override;
void ChangeDiskSpaceTopicsTotalBytes(ui64 value) override;
void ChangeDiskSpaceQuotaExceeded(i64 delta) override;
void ChangeDiskSpaceHardQuotaBytes(i64 delta) override;
Expand Down
Loading