-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[fix](metric) Change partition near-limit metrics from counters to gauges #61845
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,8 @@ protected void runAfterCatalogReady() { | |
| long tabletCount = 0L; | ||
| long partitionCount = 0L; | ||
| long tableCount = 0L; | ||
| long autoPartitionNearLimitCount = 0L; | ||
| long dynamicPartitionNearLimitCount = 0L; | ||
| List<Long> dbIds = Env.getCurrentInternalCatalog().getDbIds(); | ||
| for (Long dbId : dbIds) { | ||
| Database db = Env.getCurrentInternalCatalog().getDbNullable(dbId); | ||
|
|
@@ -162,7 +164,24 @@ protected void runAfterCatalogReady() { | |
| } | ||
| try { | ||
| List<Partition> allPartitions = olapTable.getAllPartitions(); | ||
| // Use getPartitionNum() (excludes temp partitions) for limit check, | ||
| // consistent with how partition limits are enforced elsewhere. | ||
| int nonTempPartitionNum = olapTable.getPartitionNum(); | ||
| partitionCount += allPartitions.size(); | ||
| // Check if this table's partition count is near the limit (>80%) | ||
| if (olapTable.getPartitionInfo().enableAutomaticPartition()) { | ||
| int limit = Config.max_auto_partition_num; | ||
| if (nonTempPartitionNum > limit * 8L / 10) { | ||
| autoPartitionNearLimitCount++; | ||
| } | ||
| } | ||
| if (olapTable.dynamicPartitionExists() | ||
| && olapTable.getTableProperty().getDynamicPartitionProperty().getEnable()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semantic mismatch for dynamic partition near-limit check. The original metric in
However, the new code here compares
Consider comparing the configured span ( DynamicPartitionProperty dpProp = olapTable.getTableProperty().getDynamicPartitionProperty();
long span = (long) dpProp.getEnd() - dpProp.getStart();
int limit = Config.max_dynamic_partition_num;
if (span > limit * 8L / 10) {
dynamicPartitionNearLimitCount++;
}This would make the gauge semantically consistent with the enforcement in Note: The auto-partition check above is correct — |
||
| int limit = Config.max_dynamic_partition_num; | ||
| if (nonTempPartitionNum > limit * 8L / 10) { | ||
| dynamicPartitionNearLimitCount++; | ||
| } | ||
| } | ||
| for (Partition partition : allPartitions) { | ||
| long partitionDataSize = 0L; | ||
| long version = partition.getVisibleVersion(); | ||
|
|
@@ -295,6 +314,8 @@ protected void runAfterCatalogReady() { | |
| // avoid ArithmeticException: / by zero | ||
| long avgTabletSize = totalTableSize / Math.max(1, tabletCount); | ||
| MetricRepo.GAUGE_AVG_TABLET_SIZE_BYTES.setValue(avgTabletSize); | ||
| MetricRepo.GAUGE_AUTO_PARTITION_NEAR_LIMIT.setValue(autoPartitionNearLimitCount); | ||
| MetricRepo.GAUGE_DYNAMIC_PARTITION_NEAR_LIMIT.setValue(dynamicPartitionNearLimitCount); | ||
|
|
||
| LOG.info("OlapTable num=" + tableCount | ||
| + ", partition num=" + partitionCount + ", tablet num=" + tabletCount | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same semantic mismatch as in
TabletStatMgr.java— the dynamic partition near-limit check should compare the configured span (end - start) againstmax_dynamic_partition_num, not the total partition count. See the detailed comment on theTabletStatMgr.javacounterpart.