RewriteDataFiles (bin-pack) re-selects the same files on every run when files are 50-75% of target and group total is ~110-150% of target
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 22/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java
- Lĩnh vực
- data-engineering
Hướng nghiên cứu
The loop comes from the group selection in the size-based rewrite planner (SizeBasedFileRewritePlanner, with its enoughContent and expectedOutputFiles logic) working with BinPackRewriteFilePlanner. Start by reading how enoughContent and expectedOutputFiles disagree for two files of 60 with target 100 and min 75, then reproduce with a unit test in the planner's test class. Done means the group is not selected when the rewrite cannot reduce the file count, while existing planner tests still pass. The maintainers have not yet chosen between the two proposed directions.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Apache Iceberg version
main (development). Same symptom as #6669; I only verified the logic by reading the current main source.
Query engine
Any engine using BinPackRewriteFilePlanner / SizeBasedFileRewritePlanner (Spark, Flink)
Please describe the bug 🐞
With default options (min-file-size = 0.75 * target, max = 1.8 * target), a group of files that are each between 50% and 75% of target and whose total is roughly 110%–150% of target is selected for rewrite, but the rewrite produces the same number of files with about the same sizes. The output files are again below min-file-size-bytes, so every later run selects and rewrites them again. rewritten_data_files_count == added_data_files_count on every run and the table never converges.
This is the same symptom as #6669, which was closed by the stale bot without a fix. Here is a concrete root cause.
Root cause
Group selection and output-file-count calculation disagree.
filterFiles: each file is <minFileSize, so each is selected (outsideDesiredFileSizeRange).filterFileGroups:enoughContent(group)isgroup.size() > 1 && inputSize(group) > targetFileSize, which is true as soon as the total exceeds target.expectedOutputFiles(inputSize)(target=100, min=75, two files of 60, total 120):numFilesWithRemainder = 2,numFilesWithoutRemainder = 1remainder (20) > minFileSize (75)? No.avgFileSizeWithoutRemainder (120) < 1.1 * target (110)? No.- So it falls to the last branch and returns 2.
- Result: 2 files in, 2 files out, each ~60 (< min). They are selected again on the next run.
For totals of 100%–110% the remainder is distributed and the result is 1 file, so it converges. The loop happens for totals of about 110%–150%.
Reproduction (unit-level)
target=100, min=75, max=180, two tasks of length 60. planFileGroups returns one group of 2 files, and expectedOutputFiles for that group is 2.
Workaround
Set min-file-size-bytes to at most 0.5 * target so that files in 50–75% are not selected. This hides the problem and changes the compaction policy for every file.
Proposed fix
Do not select a group by enoughContent unless the rewrite can reduce the file count:
enoughContent(group) = group.size() > 1
&& inputSize(group) > targetFileSize
&& expectedOutputFiles(inputSize(group)) < group.size()
enoughInputFiles and tooMuchContent (files above max) are left unchanged. I would like to send a PR with unit tests if this direction is acceptable.
Open questions / trade-offs
- The guard above leaves such pairs (e.g. 60+60) as two small files forever, because
expectedOutputFilesrefuses to merge into one file larger than 1.1 * target. An alternative is to relax that rule (merge when the average is belowmaxFileSize), which reduces the file count but produces files above 1.1 * target. Which direction do maintainers prefer? enoughInputFilesis independent of the output count, so users withmin-input-files=2would still hit the loop. Should the same guard apply there?- Should the guard also apply to the position-delete rewrite planner, which shares
SizeBasedFileRewritePlanner? - I have not verified the interaction with a different output partition spec (see #15465), where rewriting without reducing the file count may still be wanted.
Willingness to contribute
- I can contribute a fix for this bug independently
- I would be willing to contribute a fix for this bug with guidance from the Iceberg community
- I cannot contribute a fix for this bug at this time
- Ngôn ngữ chính
- Java
- Star
- 9.5k
- Fork
- 3.7k
- Merge trung bình
- 2 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 170
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/iceberg
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Spark: Test INSERT targets with computed IDENTIFIER expressionsCó thể đã có người làm @shivadarshan-devadiga đã nhận 15 ngày trước. Đang mởimprovement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Core] TestAvroPartitionStatsHandler fails on Windows due to unclosed partition statistics scanCó thể đã có người làm @Ankitkj1999 đã nhận 17 ngày trước. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Core: TableMetadata.Builder allows adding encryption keys to v1/v2 tablesCó thể đã có người làm @yusufyildiz34 đã nhận 37 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/iceberg#18632 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Kafka: Filter empty strings and whitespace in IcebergSinkConfig stringToListCó thể đã có người làm @mohamed-elbrik đã nhận 42 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/iceberg
Issue tương tự
-
bug vault
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
bancolombia/secrets-manager#150 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
HexaHexes/neoforge-mod-template#124 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
awaiting triage java new feature P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
source-survicate: pagination reads pagination and stops after one page; substreams drop survey_idĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
OpenLiberty/open-liberty#36410 ·
Maintainer thường phản hồi trong vòng 1 ngày