-
Notifications
You must be signed in to change notification settings - Fork 3.8k
branch-4.1: [improve](partition) Increase partition limit defaults to 20000 and add near-limit metrics #61511 #61765
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 |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ | |
| import org.apache.doris.common.FeConstants; | ||
| import org.apache.doris.common.FeNameFormat; | ||
| import org.apache.doris.common.UserException; | ||
| import org.apache.doris.metric.MetricRepo; | ||
| import org.apache.doris.policy.StoragePolicy; | ||
| import org.apache.doris.resource.Tag; | ||
| import org.apache.doris.thrift.TStorageMedium; | ||
|
|
@@ -641,10 +642,20 @@ public static Map<String, String> analyzeDynamicPartition(Map<String, String> pr | |
| } | ||
| expectCreatePartitionNum = (long) end - start; | ||
|
|
||
| if (!isReplay && hasEnd && (expectCreatePartitionNum > Config.max_dynamic_partition_num) | ||
| int dynamicPartitionLimit = Config.max_dynamic_partition_num; | ||
| if (!isReplay && hasEnd | ||
| && Boolean.parseBoolean(analyzedProperties.getOrDefault(DynamicPartitionProperty.ENABLE, "true"))) { | ||
| throw new DdlException("Too many dynamic partitions: " | ||
| + expectCreatePartitionNum + ". Limit: " + Config.max_dynamic_partition_num); | ||
| if (expectCreatePartitionNum > dynamicPartitionLimit) { | ||
| throw new DdlException("Too many dynamic partitions: " | ||
| + expectCreatePartitionNum + ". Limit: " + dynamicPartitionLimit); | ||
| } else if (expectCreatePartitionNum > dynamicPartitionLimit * 8L / 10) { | ||
| LOG.warn("Dynamic partition count {} is approaching limit {} (>80%)." | ||
| + " Consider increasing max_dynamic_partition_num.", | ||
| expectCreatePartitionNum, dynamicPartitionLimit); | ||
| if (MetricRepo.isInit) { | ||
| MetricRepo.COUNTER_DYNAMIC_PARTITION_NEAR_LIMIT.increase(1L); | ||
| } | ||
|
Comment on lines
+652
to
+657
|
||
| } | ||
| } | ||
|
|
||
| if (properties.containsKey(DynamicPartitionProperty.START_DAY_OF_MONTH)) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -96,6 +96,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.doris.load.routineload.RoutineLoadManager; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.doris.master.MasterImpl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.doris.meta.MetaContext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.doris.metric.MetricRepo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.doris.mysql.privilege.AccessControllerManager; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.doris.mysql.privilege.PrivPredicate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.doris.nereids.trees.plans.PlanNodeAndHash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -3795,15 +3796,24 @@ public TCreatePartitionResult createPartition(TCreatePartitionRequest request) t | |||||||||||||||||||||||||||||||||||||||||||||||||||
| // check partition's number limit. because partitions in addPartitionClauseMap may be duplicated with existing | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // partitions, which would lead to false positive. so we should check the partition number AFTER adding new | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // partitions using its ACTUAL NUMBER, rather than the sum of existing and requested partitions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (olapTable.getPartitionNum() > Config.max_auto_partition_num) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| int partitionNum = olapTable.getPartitionNum(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| int autoPartitionLimit = Config.max_auto_partition_num; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (partitionNum > autoPartitionLimit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| String errorMessage = String.format( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "partition numbers %d exceeded limit of variable max_auto_partition_num %d", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| olapTable.getPartitionNum(), Config.max_auto_partition_num); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| partitionNum, autoPartitionLimit); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG.warn(errorMessage); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| errorStatus.setErrorMsgs(Lists.newArrayList(errorMessage)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| result.setStatus(errorStatus); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG.warn("send create partition error status: {}", result); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (partitionNum > autoPartitionLimit * 8 / 10) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (partitionNum > autoPartitionLimit * 8 / 10) { | |
| } else if ((long) partitionNum * 10 > (long) autoPartitionLimit * 8) { |
Copilot
AI
Mar 26, 2026
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.
This warning (and counter increment) will trigger on every createPartition call once the table is above the 80% threshold, which can produce noisy logs and rapidly increasing counters in busy clusters. Consider adding throttling/deduping (e.g., log at most once per table per time window, or only when crossing the threshold) and similarly gate the metric increment to threshold-crossing events rather than per-request.
| } else if (partitionNum > autoPartitionLimit * 8 / 10) { | |
| LOG.warn("Table {}.{} auto partition count {} is approaching limit {} (>80%)." | |
| + " Consider increasing max_auto_partition_num.", | |
| db.getFullName(), olapTable.getName(), partitionNum, autoPartitionLimit); | |
| if (MetricRepo.isInit) { | |
| MetricRepo.COUNTER_AUTO_PARTITION_NEAR_LIMIT.increase(1L); | |
| } | |
| } else { | |
| // Only emit the warning and increment the metric when crossing the 80% threshold. | |
| // Estimate the partition count before this request by subtracting the number of | |
| // partitions requested to be added. This avoids noisy logs/metrics when the table | |
| // is already above the threshold. | |
| int prevPartitionNumEstimate = partitionNum - addPartitionClauseMap.size(); | |
| if (prevPartitionNumEstimate < 0) { | |
| prevPartitionNumEstimate = 0; | |
| } | |
| int threshold80 = autoPartitionLimit * 8 / 10; | |
| if (partitionNum > threshold80 && prevPartitionNumEstimate <= threshold80) { | |
| LOG.warn("Table {}.{} auto partition count {} is approaching limit {} (>80%)." | |
| + " Consider increasing max_auto_partition_num.", | |
| db.getFullName(), olapTable.getName(), partitionNum, autoPartitionLimit); | |
| if (MetricRepo.isInit) { | |
| MetricRepo.COUNTER_AUTO_PARTITION_NEAR_LIMIT.increase(1L); | |
| } | |
| } |
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.
The Chinese description still says the default is 2000 (“默认 2000。”) but the actual default was changed to 20000. Update the Chinese string to match the new default to avoid misleading operators.