Repository navigation
[core] Avoid eager manifest reads for append-only LIMIT scans - #10153
Conversation
Signed-off-by: Beinan <soros.wang@yahoo.com>
|
Requirement fit: SUPPORTED. Avoiding eager reads of all ADD manifests for an append-only LIMIT scan has a direct planning benefit, and this uses the existing bounded reader without adding an option. Implementation: CLEAN in the changed path. I checked normal scan and iterator callers, the ADD/DELETE merge path, and fallbacks for data predicates, deletion vectors, and data evolution. I found no actionable regression. Verification: the 9 new real-file/manifest tests and the core reactor package build passed locally (JDK 8, offline). In a broader TableScanTest run, 20/23 passed; three unrelated postpone-merge cases hit a local AvroSchemaConverter NoSuchMethodError from a preinstalled dependency mismatch. CI was still running when reviewed. The local base predates this PR base by about two days, so green CI on the current base remains necessary. |
Akash3121
left a comment
There was a problem hiding this comment.
The optimization is correct because readAndMergeFileEntries still reads all DELETE identifiers first, before lazily consuming ADD manifests. Later DELETE entries therefore continue to invalidate earlier ADDs. Only eligible append-only LIMIT scans switch to the bounded sequential reader; scans with data predicates, deletion vectors, data evolution, no limit, or a non-positive limit retain the previous path. Partition-only predicates remain safe because they filter manifests/files before row-count accumulation.
Purpose
Avoid scheduling every manifest read before an append-only LIMIT scan can stop.
AppendOnlyFileStoreScan.readManifestEntriesalready stops consuming entries once it has enough rows, but its normal planning path first callssuper.readManifestEntries(..., false). That eagerly submits reads for all candidate manifests, so evenLIMIT 1can perform table-wide manifest I/O.Use the existing sequential batched reader when the scan is eligible for limit pruning. The batch size continues to follow
scan.manifest.parallelism; no new option is introduced. Scans with no positive limit, data predicates, deletion vectors, or data evolution keep their existing path. Primary-key scans are unchanged.The normal ADD/DELETE merge is preserved: manifests containing DELETE entries are still processed before selecting live ADD entries. Manifest lists and required deletion metadata are still read, and the current batch may finish after the limit is reached. This change bounds ADD-manifest scheduling rather than promising exactly one physical read for every LIMIT query.
Tests
Add
AppendOnlyLimitManifestReadTest, which writes real Avro data and manifests, counts manifest input-stream opens, and reads the planned data. It covers partitioned/unpartitioned tables, limits of 1/10/larger than the table, no limit, partition/data predicates, later deletion entries, and an empty table. The consuming reader enforces the global limit, as scan pruning retains whole files.With 20 manifests, four rows per data file, and
scan.manifest.parallelism=1:Negative control: all four I/O regressions fail with the original implementation, with no test errors. All nine new test cases pass with the fix.
The final focused suite passed 56 tests, zero failures/errors/skips, including existing table-scan, append-only, primary-key, deletion-vector, and data-evolution LIMIT cases. The run used the normal Maven profile, so Checkstyle, Spotless, and enforcer checks also passed.
Validation used JDK 17 targeting Java 8, with actual local filesystem data. It did not run a StarRocks SQL cluster or object-store performance benchmark. Downstream engines such as StarRocks must consume a release/backport containing this SDK change to benefit.