[feature](multi-catalog) Add max_file_split_num session variable to prevent OOM in file scan#58759
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
2 similar comments
|
run buildall |
|
run buildall |
TPC-H: Total hot run time: 34570 ms |
TPC-DS: Total hot run time: 180264 ms |
ClickBench: Total hot run time: 27.19 s |
|
run buildall |
TPC-H: Total hot run time: 34415 ms |
TPC-DS: Total hot run time: 180789 ms |
ClickBench: Total hot run time: 27.57 s |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
fe/fe-core/src/main/java/org/apache/doris/datasource/FileQueryScanNode.java
Outdated
Show resolved
Hide resolved
9060536 to
7c2c774
Compare
54bf9ca to
10f5780
Compare
|
run buildall |
|
run buildall |
TPC-H: Total hot run time: 30962 ms |
TPC-DS: Total hot run time: 172276 ms |
ClickBench: Total hot run time: 27.07 s |
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
TPC-H: Total hot run time: 30690 ms |
TPC-DS: Total hot run time: 172452 ms |
ClickBench: Total hot run time: 27.11 s |
FE Regression Coverage ReportIncrement line coverage |
fe/fe-core/src/main/java/org/apache/doris/datasource/hive/source/HiveScanNode.java
Show resolved
Hide resolved
|
PR approved by anyone and no changes requested. |
FE Regression Coverage ReportIncrement line coverage |
|
PR approved by at least one committer and no changes requested. |
…revent OOM in file scan (apache#58759) ### What problem does this PR solve? - Relate Pr: apache#58858 ## Problem Summary When querying external table catalog (Hive, Iceberg, Paimon, etc.), Doris splits files into multiple splits for parallel processing. In some cases, especially with numerous small files, this can generate an excessive number of splits, potentially causing: 1. **Memory pressure**: Too many splits consume significant memory in FE 2. **OOM issues**: Excessive split generation can lead to OutOfMemoryError 3. **Performance degradation**: Managing too many splits impacts query planning overhead Previously, there was no upper limit on the number of splits in non-batch mode, which could lead to problems when querying tables with many small files. ## Solution This PR introduces a new session variable `max_file_split_num` to limit the maximum number of splits allowed per table scan in non-batch mode. ### Changes 1. **New Session Variable**: `max_file_split_num` - Type: `int` - Default: `100000` - Description: "在非 batch 模式下,每个 table scan 最大允许的 split 数量,防止产生过多 split 导致 OOM。" - Forward to BE: `true` 2. **Implementation in FileQueryScanNode**: - Added method `applyMaxFileSplitNumLimit(long targetSplitSize, long totalFileSize)` - Dynamically calculates minimum split size to ensure split count doesn't exceed the limit - Formula: `minSplitSizeForMaxNum = (totalFileSize + maxFileSplitNum - 1) / maxFileSplitNum` - Returns: `Math.max(targetSplitSize, minSplitSizeForMaxNum)` 3. **Applied to multiple scan nodes**: - `HiveScanNode` - `IcebergScanNode` - `PaimonScanNode` - `TVFScanNode` 4. **Unit Tests**: - `FileQueryScanNodeTest`: Test base logic - `HiveScanNodeTest`: Test Hive-specific implementation - `IcebergScanNodeTest`: Test Iceberg-specific implementation - `PaimonScanNodeTest`: Test Paimon-specific implementation - `TVFScanNodeTest`: Test TVF-specific implementation ## Usage Users can now control the maximum number of splits per table scan by setting the session variable: ```sql -- Set to 50000 splits maximum SET max_file_split_num = 50000; -- Disable the limit (set to 0 or negative) SET max_file_split_num = 0; ``` (cherry picked from commit 3e5a70f)
This reverts commit cb4634a.
What problem does this PR solve?
Problem Summary
When querying external table catalog (Hive, Iceberg, Paimon, etc.), Doris splits files into multiple splits for parallel processing. In some cases, especially with numerous small files, this can generate an excessive number of splits, potentially causing:
Previously, there was no upper limit on the number of splits in non-batch mode, which could lead to problems when querying tables with many small files.
Solution
This PR introduces a new session variable
max_file_split_numto limit the maximum number of splits allowed per table scan in non-batch mode.Changes
New Session Variable:
max_file_split_numint100000trueImplementation in FileQueryScanNode:
applyMaxFileSplitNumLimit(long targetSplitSize, long totalFileSize)minSplitSizeForMaxNum = (totalFileSize + maxFileSplitNum - 1) / maxFileSplitNumMath.max(targetSplitSize, minSplitSizeForMaxNum)Applied to multiple scan nodes:
HiveScanNodeIcebergScanNodePaimonScanNodeTVFScanNodeUnit Tests:
FileQueryScanNodeTest: Test base logicHiveScanNodeTest: Test Hive-specific implementationIcebergScanNodeTest: Test Iceberg-specific implementationPaimonScanNodeTest: Test Paimon-specific implementationTVFScanNodeTest: Test TVF-specific implementationUsage
Users can now control the maximum number of splits per table scan by setting the session variable:
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)