Skip to content

branch-4.1: [fix](fe) Stop split enumeration when queries finish or terminate - #70004

Merged
yiguolei merged 2 commits into
apache:branch-4.1from
CalvinKirs:backport-69835-branch-4.1
Nov 4, 2026
Merged

yiguolei merged 2 commits into
apache:branch-4.1from
CalvinKirs:backport-69835-branch-4.1

Conversation

@CalvinKirs

Copy link
Copy Markdown
Member

### What problem does this PR solve?

Issue Number: None

Related PR: apache#69835

Problem Summary: Hive and Iceberg split enumeration can outlive LIMIT completion,
query cancellation, and planning timeout. Retained queues and queued background
tasks keep scan resources alive, while the first split wait is fixed at 30 seconds.
Adapt the merged fix to the existing branch-4.1 execution paths without backporting
Hive streaming, fair scheduling, changed batch defaults, or the Connector SPI migration.
Share a cancellation-aware task owner, stop request pagination and split generation,
remove queued tasks, retain read resources until actual worker/source termination,
and propagate cancellation before coordinator publication. Keep release batch-mode
thresholds and queue units unchanged.

Backport source: ea3558d

### Release note

External batch scans stop enumeration and release split queues when queries finish,
are cancelled, or time out. The first_split_wait_timeout_ms session variable controls
the initial split wait (default 30000 ms); timeout errors include enumeration progress.

### Check List (For Author)

- Test: Unit Test - 345 distinct targeted FE tests passed using run-fe-ut.sh,
  across the expanded run and the corrected Hive fixture rerun; Checkstyle passed.
  Production compilation passed; final packaging and end-to-end validation pending.
- Behavior changed: Yes - cooperative early stop and configurable first split wait.
- Does this need documentation: Yes - first_split_wait_timeout_ms; documentation pending.
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#69835

Problem Summary: On branch-4.1, cancellable Hive global file-cache misses must retain the catalog-specific filesystem lister, and TABLESAMPLE must pass cancellation through selection and per-file splitting. Iceberg weighted caches return a query-scoped table that must keep snapshot isolation when installing guarded FileIO and tracking manifest planning tasks. Preserve producer failures during endpoint cleanup and close registered scan tasks when internal-query planning fails before a coordinator exists.

### Release note

Complete split early-stop behavior for sampled Hive scans, weighted Iceberg metadata caches, and internal-query planning failures.

### Check List (For Author)

- Test: Unit Test
    - 476 FE tests passed across 20 relevant classes using run-fe-ut.sh; Checkstyle passed with 0 violations
- Behavior changed: Yes (stop omitted scan paths and preserve native cache isolation and error details)
- Does this need documentation: No (covered by the original early-stop change)
@CalvinKirs
CalvinKirs marked this pull request as ready for review November 3, 2026 06:33
@CalvinKirs
CalvinKirs requested a review from yiguolei as a code owner November 3, 2026 06:33
@CalvinKirs

Copy link
Copy Markdown
Member Author

branch-4.1 backport validation and performance

Validated head: 5b90e691fce12665de078bb7b944357dfdc2ac72.
Baseline: dd72933ec78a8a4daf3e1d204a6ea96d6443ada7 on branch-4.1, before this backport. Both sides use the same BE 4.1.3 package (doris-4.1.3-rc02-7126cf65d96).

Test conditions

  • Hive tables through a local Docker HMS, with real OSS and a dedicated HDFS fixture. Each partition contains 100 small Parquet files. The 100-, 1,000-, and 10,000-partition tables contain 10,000, 100,000, and 1,000,000 files respectively.
  • One serial query at a time. Both versions use one file-listing worker and one scheduling worker. Remaining relevant settings use branch-4.1 defaults, including the 1,024-partition threshold; the candidate's producer-parallelism setting stays at its default.
  • Same machine, CPU allocation, 4 GiB FE heap, and 6 GiB BE limit on both sides. An initial 3 GiB BE series was discarded after a baseline OOM; the reported comparison was rerun with 6 GiB on both sides.
  • Main comparison order: candidate / baseline / baseline / candidate, with two fresh FE processes per version. Each scenario has 20 measured samples per version, following warm-up. All reported times are median SQL wall time in milliseconds.
  • "Fresh catalog" means a newly created FE catalog. It does not imply cold OSS service caches or cold OS caches. "Warm" means repeated queries after warm-up in the same catalog. Native listing workers and BE readers were checked for idleness around queries.
  • Performance timing runs use normal binaries. Resource/SDK observation is performed separately from timing.

Here t100, t1000, and t10000 are shorthand for the three table sizes. LIMIT SQL is SELECT * FROM tN LIMIT 10; full-scan SQL is SELECT SUM(id) FROM t100; filtered full-scan SQL is SELECT SUM(id) FROM t10000 WHERE p < 100. The two SUM scenarios read the same 100 partition directories / 10,000 physical files, verified through HMS.

Main performance comparison

Change = (after / before - 1) * 100%; a negative value means lower latency.

Storage Scenario Before (ms) After (ms) Change
OSS 100 partitions, LIMIT 10, fresh catalog 1,606.6 1,643.7 +2.3%
OSS 100 partitions, LIMIT 10, warm 231.6 223.0 -3.7%
OSS 1,000 partitions, LIMIT 10, fresh catalog 14,746.0 14,918.1 +1.2%
OSS 1,000 partitions, LIMIT 10, warm 2,218.3 2,200.7 -0.8%
OSS 10,000 partitions, LIMIT 10, fresh catalog 1,087.5 584.1 -46.3%
OSS 10,000 partitions, LIMIT 10, warm 190.7 113.6 -40.5%
OSS 100 partitions, SUM 1,397.4 1,392.9 -0.3%
OSS 10,000 partitions, SUM with p < 100 1,390.3 1,441.3 +3.7%
HDFS 100 partitions, LIMIT 10, fresh catalog 545.6 553.2 +1.4%
HDFS 100 partitions, LIMIT 10, warm 235.1 234.5 -0.3%
HDFS 1,000 partitions, LIMIT 10, fresh catalog 5,327.1 5,262.6 -1.2%
HDFS 1,000 partitions, LIMIT 10, warm 2,173.4 2,146.1 -1.3%
HDFS 10,000 partitions, LIMIT 10, fresh catalog 789.3 223.8 -71.6%
HDFS 10,000 partitions, LIMIT 10, warm 132.3 42.6 -67.8%
HDFS 100 partitions, SUM 1,187.4 1,086.8 -8.5%
HDFS 10,000 partitions, SUM with p < 100 1,002.5 1,044.8 +4.2%

The 10,000-partition LIMIT improvement reproduced in both execution orders for both storage systems. Smaller LIMIT scenarios did not show a stable improvement or regression across orders. These sizes remain below the existing 1,024-partition threshold, so the results should not be extrapolated as a uniform speedup for every table size.

Additional confirmation of the slower filtered-SUM cases

The main series showed roughly 4% higher medians for filtered SUM. These cases were repeated with 60 measured samples per version per scenario, baseline / candidate / candidate / baseline process order, and alternating full-SUM / filtered-SUM query order. These are separate samples from the main table.

Storage Scenario Before (ms) After (ms) Change 95% descriptive bootstrap interval for change
OSS 100 partitions, SUM 1,368.7 1,374.9 +0.45% [-1.15%, +2.91%]
OSS 10,000 partitions, SUM with p < 100 1,396.1 1,399.7 +0.26% [-1.54%, +2.23%]
HDFS 100 partitions, SUM 1,023.8 1,025.0 +0.12% [-6.49%, +5.32%]
HDFS 10,000 partitions, SUM with p < 100 1,046.7 1,029.6 -1.64% [-9.18%, +5.31%]

The initial ~4% filtered-SUM slowdown was not consistently reproduced: the sign changed between process orders in the confirmation runs. The intervals include zero. This does not prove zero overhead; the machine is shared, and there are only two FE processes per version in each series. The bootstrap intervals describe the collected query samples and do not capture all process-level or host-level variability.

Across the main and confirmation series, 1,120 timed queries and 368 warm-up queries completed successfully. Pilot queries and the discarded 3 GiB series are outside these totals. A confirmation-run stop-controller failure occurred after that round's queries had succeeded; process exit was checked before resuming the remaining baseline round with the same settings.

Functional and resource acceptance

Acceptance fixture: Hive, local HMS + real OSS, 10,000 partitions x 100 files, common BE 4.1.3.

Acceptance scenario Result
LIMIT 10 completes normally, 3 repetitions Background termination after the stop signal: 1 / 113 / 103 ms; maximum 113 ms
SUM canceled during active Split enumeration, 3 repetitions Background termination: 288 / 186 / 118 ms; maximum 288 ms
SUM hits a 3-second query timeout, 3 repetitions Background termination: 313 / 209 / 248 ms; maximum 313 ms
First-Split wait configured to 1,000 ms and 2,500 ms Both waits report the configured deadline and enumeration progress in the error
Resource release, all 11 acceptance cases Queue and queued ranges empty; active producers/runs, listeners, and resources zero; termination completed; query callback registry empty
Requests after stopping No new observed SDK HTTP dispatch after stop + 10 seconds, with a 12-second observation window

Example first-Split timeout error:

Timed out waiting for the first split after 1000 ms: partitions_processed=0/10000, files_enumerated=0, splits_generated=0, active_producers=1

The first-Split timer starts when waiting for the first Split; total SQL wall time also includes earlier planning. The two first-wait cases inject a 5-second SDK delay to exercise cleanup while an SDK call is in progress. Their background termination times after the timeout signal were 4,221 ms and 2,783 ms, both below 10 seconds. An in-flight SDK call can finish after cancellation; this result does not imply instantaneous interruption at the stop signal.

The request observer covers the AWS SDK 2.29.52 UrlConnectionHttpClient.RequestCallable dispatch to HttpURLConnection.connect; internal JDK retries are not separately counted. Hive end-to-end acceptance passed 11/11. Iceberg was covered by code review and unit tests; equivalent Iceberg cluster acceptance was not performed in this round.

Other verification

  • FE unit tests: 476 passed, zero failures/errors/skips.
  • FE build through build.sh --fe: passed.
  • Checkstyle and git diff --check: passed.

Benchmark scripts, data, runtime configuration, and build workarounds are excluded from this PR's source changes. No associated prerequisite PRs were separately backported.

@CalvinKirs

Copy link
Copy Markdown
Member Author

run buildall

@yiguolei
yiguolei merged commit a58b5dd into apache:branch-4.1 Nov 4, 2026
33 of 35 checks passed
@CalvinKirs
CalvinKirs deleted the backport-69835-branch-4.1 branch November 4, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants