Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Storage Quota Utilization Metric Emission for Realtime Tables #14780

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public QuotaCheckerResponse isSegmentStorageWithinQuota(TableConfig tableConfig,
// when we are checking the quota for only existing segments (segmentSizeInBytes == 0)
// as in both cases quota is checked across existing segments estimated size alone
if (segmentSizeInBytes == 0 || tableSubtypeSize._missingSegments > 0) {
emitStorageQuotaUtilizationMetric(tableNameWithType, tableSubtypeSize, allowedStorageBytes);
if (tableSubtypeSize._estimatedSizeInBytes > allowedStorageBytes) {
return failure("Table " + tableNameWithType + " already over quota. Estimated size for all replicas is "
+ DataSizeUtils.fromBytes(tableSubtypeSize._estimatedSizeInBytes) + ". Configured size for " + numReplicas
Expand All @@ -147,14 +148,7 @@ public QuotaCheckerResponse isSegmentStorageWithinQuota(TableConfig tableConfig,
LOGGER.info("Table {}'s estimatedSizeInBytes is {}. ReportedSizeInBytes (actual reports from servers) is {}",
tableNameWithType, tableSubtypeSize._estimatedSizeInBytes, tableSubtypeSize._reportedSizeInBytes);

// Only emit the real percentage of storage quota usage by lead controller, otherwise emit 0L.
if (_leadControllerManager.isLeaderForTable(tableNameWithType)) {
long existingStorageQuotaUtilization = tableSubtypeSize._estimatedSizeInBytes * 100 / allowedStorageBytes;
_controllerMetrics.setValueOfTableGauge(tableNameWithType, ControllerGauge.TABLE_STORAGE_QUOTA_UTILIZATION,
existingStorageQuotaUtilization);
} else {
_controllerMetrics.setValueOfTableGauge(tableNameWithType, ControllerGauge.TABLE_STORAGE_QUOTA_UTILIZATION, 0L);
}
emitStorageQuotaUtilizationMetric(tableNameWithType, tableSubtypeSize, allowedStorageBytes);

// Note: incomingSegmentSizeBytes is uncompressed data size for just 1 replica,
// while estimatedFinalSizeBytes is for all replicas of all segments put together.
Expand Down Expand Up @@ -217,6 +211,18 @@ public QuotaCheckerResponse isSegmentStorageWithinQuota(TableConfig tableConfig,
}
}

private void emitStorageQuotaUtilizationMetric(String tableNameWithType, TableSizeReader.TableSubTypeSizeDetails
tableSubtypeSize, long allowedStorageBytes) {
// Only emit the real percentage of storage quota usage by lead controller, otherwise emit 0L.
if (_leadControllerManager.isLeaderForTable(tableNameWithType)) {
long existingStorageQuotaUtilization = tableSubtypeSize._estimatedSizeInBytes * 100 / allowedStorageBytes;
_controllerMetrics.setValueOfTableGauge(tableNameWithType, ControllerGauge.TABLE_STORAGE_QUOTA_UTILIZATION,
existingStorageQuotaUtilization);
} else {
_controllerMetrics.setValueOfTableGauge(tableNameWithType, ControllerGauge.TABLE_STORAGE_QUOTA_UTILIZATION, 0L);
}
}

/**
* Checks whether the table is within the storage quota.
* @return true if storage quota is exceeded by the table, else false.
Expand Down
Loading