@@ -38,10 +38,10 @@ EDiskUsageStatus CheckStoragePoolsQuotas(const THashMap<TString, TStoragePoolUsa
3838 for (const auto & [poolKind, usage] : storagePoolsUsage) {
3939 if (const auto * quota = storagePoolsQuotas.FindPtr (poolKind)) {
4040 const auto totalSize = usage.DataSize + usage.IndexSize ;
41- if (totalSize > quota->HardQuota ) {
41+ if (quota-> HardQuota && totalSize > quota->HardQuota ) {
4242 return EDiskUsageStatus::AboveHardQuota;
4343 }
44- if (totalSize > quota->SoftQuota ) {
44+ if (quota-> SoftQuota && totalSize >= quota->SoftQuota ) {
4545 softQuotaExceeded = true ;
4646 }
4747 }
@@ -95,19 +95,19 @@ TDiskSpaceQuotas TSubDomainInfo::GetDiskSpaceQuotas() const {
9595 }
9696
9797 THashMap<TString, TQuotasPair> storagePoolsQuotas;
98- for (const auto & storagePoolQuota : DatabaseQuotas->storage_pools_quotas ()) {
99- ui64 storagePoolHardQuota = storagePoolQuota .data_size_hard_quota ();
100- ui64 storagePoolSoftQuota = storagePoolQuota .data_size_soft_quota ();
98+ for (const auto & storageQuota : DatabaseQuotas->storage_quotas ()) {
99+ ui64 unitHardQuota = storageQuota .data_size_hard_quota ();
100+ ui64 unitSoftQuota = storageQuota .data_size_soft_quota ();
101101
102- if (!storagePoolSoftQuota ) {
103- storagePoolSoftQuota = storagePoolHardQuota ;
104- } else if (!storagePoolHardQuota ) {
105- storagePoolHardQuota = storagePoolSoftQuota ;
102+ if (!unitSoftQuota ) {
103+ unitSoftQuota = unitHardQuota ;
104+ } else if (!unitHardQuota ) {
105+ unitHardQuota = unitSoftQuota ;
106106 }
107107
108- storagePoolsQuotas.emplace (storagePoolQuota. storage_pool_kind (), TQuotasPair{
109- .HardQuota = storagePoolHardQuota ,
110- .SoftQuota = storagePoolSoftQuota
108+ storagePoolsQuotas.emplace (storageQuota. unit_kind (), TQuotasPair{
109+ .HardQuota = unitHardQuota ,
110+ .SoftQuota = unitSoftQuota
111111 }
112112 );
113113 }
@@ -139,13 +139,19 @@ bool TSubDomainInfo::CheckDiskSpaceQuotas(IQuotaCounters* counters) {
139139
140140 ui64 totalUsage = TotalDiskSpaceUsage ();
141141 const auto storagePoolsUsageStatus = CheckStoragePoolsQuotas (DiskSpaceUsage.Tables .StoragePoolsUsage , quotas.StoragePoolsQuotas );
142- if (quotas.HardQuota && totalUsage > quotas.HardQuota
143- || !quotas.StoragePoolsQuotas .empty () && storagePoolsUsageStatus == EDiskUsageStatus::AboveHardQuota) {
142+
143+ // Quota being equal to zero is treated as if there is no limit on disk space usage.
144+ const bool overallHardQuotaIsExceeded = quotas.HardQuota && totalUsage > quotas.HardQuota ;
145+ const bool someStoragePoolHardQuotaIsExceeded = !quotas.StoragePoolsQuotas .empty ()
146+ && storagePoolsUsageStatus == EDiskUsageStatus::AboveHardQuota;
147+ if (overallHardQuotaIsExceeded || someStoragePoolHardQuotaIsExceeded) {
144148 return changeSubdomainState (EDiskUsageStatus::AboveHardQuota);
145149 }
146150
147- if ((!quotas.SoftQuota || totalUsage < quotas.SoftQuota )
148- && (quotas.StoragePoolsQuotas .empty () || storagePoolsUsageStatus == EDiskUsageStatus::BelowSoftQuota)) {
151+ const bool totalUsageIsBelowOverallSoftQuota = !quotas.SoftQuota || totalUsage < quotas.SoftQuota ;
152+ const bool allStoragePoolsUsageIsBelowSoftQuota = quotas.StoragePoolsQuotas .empty ()
153+ || storagePoolsUsageStatus == EDiskUsageStatus::BelowSoftQuota;
154+ if (totalUsageIsBelowOverallSoftQuota && allStoragePoolsUsageIsBelowSoftQuota) {
149155 return changeSubdomainState (EDiskUsageStatus::BelowSoftQuota);
150156 }
151157
@@ -1495,6 +1501,11 @@ void TTableInfo::SetPartitioning(TVector<TTableShardInfo>&& newPartitioning) {
14951501 newAggregatedStats.RowCount += newStats.RowCount ;
14961502 newAggregatedStats.DataSize += newStats.DataSize ;
14971503 newAggregatedStats.IndexSize += newStats.IndexSize ;
1504+ for (const auto & [poolKind, newStoragePoolStats] : newStats.StoragePoolsStats ) {
1505+ auto & aggregatedStoragePoolStats = newAggregatedStats.StoragePoolsStats [poolKind];
1506+ aggregatedStoragePoolStats.DataSize += newStoragePoolStats.DataSize ;
1507+ aggregatedStoragePoolStats.IndexSize += newStoragePoolStats.IndexSize ;
1508+ }
14981509 newAggregatedStats.InFlightTxCount += newStats.InFlightTxCount ;
14991510 cpuTotal += newStats.GetCurrentRawCpuUsage ();
15001511 newAggregatedStats.Memory += newStats.Memory ;
@@ -1591,7 +1602,7 @@ void TAggregatedStats::UpdateShardStats(TShardIdx datashardIdx, const TPartition
15911602 for (const auto & [poolKind, oldStoragePoolStats] : oldStats.StoragePoolsStats ) {
15921603 if (const auto * newStoragePoolStats = newStats.StoragePoolsStats .FindPtr (poolKind); !newStoragePoolStats) {
15931604 auto * aggregatedStoragePoolStats = Aggregated.StoragePoolsStats .FindPtr (poolKind);
1594- Y_ENSURE (aggregatedStoragePoolStats); // How else could it be present in the oldStats?
1605+ Y_ABORT_UNLESS (aggregatedStoragePoolStats, " Old stats are present, but they haven't been aggregated. " );
15951606
15961607 // Missing new stats for a particular storage pool are interpreted as if this data
15971608 // has been removed from the datashard and we need to subtract the old stats' sizes from the aggregate.
0 commit comments