Skip to content

[fix](runtime-filter) Release completed RF merge query contexts safely - #70305

Draft
mrhhsg wants to merge 5 commits into
apache:masterfrom
mrhhsg:fix/rf-merge-context-lifecycle
Draft

mrhhsg wants to merge 5 commits into
apache:masterfrom
mrhhsg:fix/rf-merge-context-lifecycle

Conversation

@mrhhsg

@mrhhsg mrhhsg commented Nov 5, 2026

Copy link
Copy Markdown
Member

Background

A backend retains an extra QueryContext reference while coordinating merged runtime filters. Destruction of that context triggers the backend's final fragment-profile report.

What problem does this PR solve?

Issue Number: None
Related PR: None
PR Type: Bugfix

Problem Summary: A successful query could retain the extra merge owner until cancellation or timeout, delaying its final profiles beyond the frontend's normal collection window. This change releases that owner after an eligible query has completed initial fragment preparation and all required remote filter dispatches and callbacks. Recursive, legacy, and duplicate-endpoint-start plans retain the conservative lifetime behavior.

Details

  • Change map: Seven production/interface files (+215/-16 lines) cover BE completion and ownership, FE eligibility, and an optional Thrift field. Seven test and expected-output files (+424/-2 lines) cover lifecycle, failure, planning, profile, and recursive cases.
  • Frequency: The delayed owner can persist after successful queries with an RF merge controller; a local-only filter can also establish that owner without any remote merge work.
  • Root cause: Normal completion had no cleanup path for the delayed owner. The existing merge-done flag precedes remote RPC dispatch and cannot prove callback completion.
  • Why existing tests missed it: They did not check post-completion ownership or timely final profiles, nor the duplicate-start case where distinct workers share a BE endpoint.
  • Fix: Track required size and publish dispatches, callback completion, and failure per merge round. Sweep completed single-use contexts and release the extra owner outside map locks, after the whole initial fragment batch is prepared. Keep old-round completion alive across reset and accept a normal size-sync EOF. FE enables this only for complete, non-recursive plans with one worker identity per BRPC endpoint.
  • Other paths and branches: A missing or false optional field preserves the previous lifetime. Recursive and duplicate-endpoint-start plans do not opt in. No release branch is changed; mixed-version execution has not been run locally.

Testing

  • BUILD_TYPE=ASAN ./build.sh --be --fe -j 50 passed locally, including FE Checkstyle.
  • Focused ./run-fe-ut.sh --run suites passed (27/27); focused ASAN ./run-be-ut.sh --run tests passed (6/6).
  • Single-BE rf_merge_context_profile, rf_merge_context_reuse, and rec_cte_parallel_targets regression suites each passed (1 suite, 0 failed).
  • build-support/clang-format.sh, build-support/check-format.sh, build-support/check-build-hygiene.sh, build-support/run-clang-tidy.sh, and git diff --check passed locally.
  • Multi-BE late-filter, controlled delayed duplicate-start, and mixed-version execution were not run locally.

Notes for Reviewers

The optional FE-to-BE field is fail-closed. The BE requires complete initial deployment, successful remote phases, and zero pending callbacks before releasing the delayed owner; live fragment contexts still retain their own QueryContext references.

Release note

Final profiles for eligible successful queries using runtime filters can be reported promptly rather than waiting for query timeout.

Check List (For Author)

  • Behavior changed: Yes (see Details)
  • Does this need documentation: No
  • Pre-submission status: Partially verified: local ASAN and single-BE validation passed; multi-BE and mixed-version execution were not run.

AI Disclosure

  • Tool: OpenAI Codex
  • Generated: Code, tests, and this description.
  • Human review: No human review was performed on the generated changes.

### Background

A backend retains an extra query-context reference while it coordinates merged runtime filters. Query-context destruction triggers the final profile report for that backend.

### What problem does this PR solve?

Issue Number: None
Related PR: None
PR Type: Bugfix

Problem Summary: The merge owner remained until cancellation or timeout after successful queries, delaying final fragment profiles. Release only the extra owner after a non-recursive query's initial fragment batch is prepared and all remote filter dispatches and callbacks are complete. Legacy and recursive queries retain the existing lifetime behavior.

### Details

- **Change map:** About 200 lines of production changes in BE lifecycle, FE planning, and an optional Thrift field; the remainder is unit and regression coverage.
- **Frequency:** Successful queries using a runtime-filter merge controller could retain the extra owner until timeout.
- **Root cause:** Normal completion had no cleanup of the delayed merge owner; the existing merge-done flag precedes RPC dispatch and cannot establish callback completion.
- **Why existing tests missed it:** Existing coverage did not assert the merge owner's lifetime after successful filter completion or a timely complete profile.
- **Fix:** Add a query-wide single-use contract, track remote size/publish dispatch and callback completion, and erase the delayed owner outside map locks. Keep local-only filters registered but exclude them from remote completion checks.
- **Other paths and branches:** Missing or false contract values preserve the previous behavior. Recursive plans do not opt in, so reset/rebuild remains protected. The optional field is backward compatible.

### Testing

- Local ASAN BE and FE build; focused BE tests repeated with randomized order; focused FE unit tests.
- Local query-profile and recursive-CTE regression suites, including a shuffle remote-filter path.
- clang-format, format check, build hygiene, clang-tidy, and diff check.

### Notes for Reviewers

The profile regression ran on a single-BE cluster. Multi-BE and mixed-version behavior remains for broader validation.

### Release note

Final profiles for successful non-recursive queries with runtime filters are reported promptly instead of being held until query timeout.

### Check List (For Author)

- Behavior changed: Yes (see Details)
- Does this need documentation: No
- Pre-submission status: Partially verified: multi-BE and mixed-version runs were not performed locally.

### AI Disclosure

- Tool: OpenAI Codex
- Generated: Code, tests, and this description.
- Human review: Pending independent review.
### Background

A backend retains a query context while coordinating merged runtime filters. Completion of the merge dispatch allows a single-use query to release this extra owner and report its final profile.

### What problem does this PR solve?

Issue Number: None
Related PR: None
PR Type: Bugfix

Problem Summary: A recursive reset could replace the completion object while an older publish call still used it, causing a use-after-free. A normal end-of-file response to a delayed size-sync RPC was also classified as a dispatch failure, preventing timely cleanup. Keep a strong reference to the publishing round's completion and treat that end-of-file response as normal.

### Details

- **Frequency:** The reset race requires a recursive filter with a concurrent old-round publish tail; delayed size-sync responses can occur after a producer finishes.
- **Root cause:** The publisher repeatedly read a replaceable shared-pointer member rather than retaining its own round's completion. The new callback failure bit did not match the existing end-of-file handling.
- **Why existing tests missed it:** The recursive regression contained no runtime filter, and synthetic ownership tests raced with a live cleanup worker. No test called the merge size callback with an end-of-file status.
- **Fix:** Snapshot the completion under the merge-context lock, use it throughout direct and tree dispatch, align callback failure classification with the existing callback, isolate synthetic ownership tests from the worker, and make the recursive regression generate a partitioned remote runtime filter.
- **Other paths and branches:** The optional single-use contract remains conservative for recursive and older plans. Transport and non-EOF application failures still prevent automatic release. No release-branch behavior is changed.

### Testing

- Local ASAN BE and FE build with FE Checkstyle; focused BE tests, including 20 randomized repetitions of 48 tests; focused FE tests (26 passed).
- Local recursive runtime-filter regression generated through the runner and passed five further repetitions; existing parallel recursive and query-profile regressions passed.
- clang-format, format check, build hygiene, clang-tidy, and diff check passed.

### Release note

Final profiles for successful single-use queries with runtime filters can be reported promptly, including when a completed producer acknowledges a delayed size-sync with end-of-file.

### Check List (For Author)

- Behavior changed: Yes (see Details)
- Does this need documentation: No
- Pre-submission status: Partially verified: local single-BE regression passed; multi-BE and mixed-version execution were not run.

### AI Disclosure

- Tool: OpenAI Codex
- Generated: Code, tests, and this description.
- Human review: Pending independent review.
### Background

FE groups pipeline fragments by worker identity and sends one phase-two start RPC for each worker. BE may release the extra RF merge QueryContext owner when an opted-in query has finished its RF work.

### What problem does this PR solve?

Issue Number: None
Related PR: None
PR Type: Bugfix

Problem Summary: Workers from different catalogs can have distinct identities but share one BE BRPC endpoint. The first start can complete the query before a second start reaches that BE; releasing the merge context then makes the late start fail. Only opt in to prompt RF merge context release when each physical endpoint has one worker identity.

### Details

- **Frequency:** Queries that use distinct catalog workers mapped to one BE endpoint and whose phase-two starts are processed far enough apart.
- **Root cause:** The single-use eligibility check excluded recursive plans but did not exclude duplicate starts to one physical endpoint.
- **Why existing tests missed it:** They covered one worker and distinct endpoints, not different catalog identities at the same endpoint.
- **Fix:** Compare every assigned worker's BRPC endpoint and worker identity across the complete plan. Fall back to the existing delayed-owner lifetime if one endpoint has multiple identities.
- **Other paths and branches:** Repeated jobs for the same worker remain eligible. Distinct endpoints remain eligible. This commit changes no wire field or release branch.

### Testing

- `./run-fe-ut.sh --run org.apache.doris.qe.runtime.ThriftPlansBuilderTest,org.apache.doris.qe.runtime.RuntimeFiltersThriftBuilderTest,org.apache.doris.common.profile.ProfileTest,org.apache.doris.common.profile.ExecutionProfileTest` (27 passed).
- `./run-be-ut.sh --run --filter='FragmentMgrCrossClusterCancelTest.LocalOnlyRfMergeOwnerReleasedAfterLastFragmentOwner:FragmentMgrCrossClusterCancelTest.MissingSingleUseContractKeepsMergeOwnerForReset:FragmentMgrCrossClusterCancelTest.RemoteRfRequiresSizeDispatchAndCallbackCompletion:FragmentMgrDelayDeleteMapTest.*:RuntimeFilterMgrTest.MergeSizeDispatchCallbackAcceptsEofButRejectsOtherFailures' -j 20` (6 passed).
- `BUILD_TYPE=ASAN ./build.sh --be --fe -j 50` (passed, including FE Checkstyle).
- Isolated single-BE `rf_merge_context_profile`, `rf_merge_context_reuse`, and `rec_cte_parallel_targets` regression suites (passed).
- `build-support/clang-format.sh`, `build-support/check-format.sh`, `build-support/check-build-hygiene.sh`, and `build-support/run-clang-tidy.sh` (passed).

### Release note

Avoid query failures when distinct catalog workers share a BE endpoint, while preserving prompt final profiles for eligible queries.

### Check List (For Author)

- Behavior changed: Yes (see Details)
- Does this need documentation: No
- Pre-submission status: Partially verified: isolated single-BE tests passed; delayed duplicate-start and multi-BE mixed-version cases were not run.

### AI Disclosure

- Tool: OpenAI Codex
- Generated: Eligibility guard, focused unit test, and this commit description.
- Human review: Not yet performed.
@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?

@mrhhsg

mrhhsg commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

/review

1 similar comment
@mrhhsg

mrhhsg commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Review recovery stopped: Could not verify exactly one final review from this invocation; first recorded API failure: GitHub API POST repos/apache/doris/pulls/70305/reviews failed (CalledProcessError, exit=1, timeout=None); stderr="unexpected end of JSON input\nGitHub request failed: POST /repos/apache/doris/pulls/70305/reviews; HTTP=500; request_id=2885:342262:1713C19:4ABC321:6AECAB14; CalledProcessError; exit=1; timeout=None"; stdout="" (see review-api-errors.jsonl)
Workflow run: https://github.com/apache/doris/actions/runs/42054481593

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all 14 changed files at commit 25d0414. No new actionable finding or independently confirmed existing P0/P1 finding. The review converged after two rounds with complete assigned static coverage and no unresolved candidates.

Critical checkpoint conclusions:

  • Goal and proof: the change releases the extra RF merge QueryContext owner after a complete eligible deployment and successful required dispatch/callback completion, enabling final profile reporting. Added unit and regression tests address eligibility, ownership gates, callback failures, timely profiles, and recursive reuse; their execution was not part of this review.
  • Scope and reuse: changes are focused on lifetime eligibility and completion accounting; existing cancellation, BRPC callback, profile, and map machinery is reused.
  • Concurrency and locks: service preparation, pipeline completion, BRPC callbacks, and the cancel worker are the concurrent actors. Batch/dispatch publication uses release/acquire atomics; pending callbacks use atomic accounting. Cleaner work and last-reference destruction occur outside map shard locks. No new lock-order inversion was substantiated.
  • Lifecycle and static initialization: live fragment contexts retain their own QueryContext references; the delayed map supplies only an extra owner. Callbacks retain per-round Completion and weak query ownership. Recursive reset preserves captured old Completion lifetime. No new strong ownership cycle or cross-translation-unit initializer dependency was found.
  • Configuration: no configuration item is added. Cleanup uses the existing cancel-worker interval.
  • Interface compatibility: missing/false eligibility preserves conservative lifetime; an old BE ignores the optional new field. No storage-format or exported function-symbol change was identified. Mixed-version execution was not run.
  • Thrift IDs: the complete TRuntimeFilterParams definition was compared on HEAD and live-verified branch-3.1, branch-4.0, branch-4.1, and branch-4.2. New optional bool field 6 is unused on those release branches; existing field meanings are preserved. This PR targets master.
  • Parallel paths: local-only, remote direct/tree, broadcast, dynamic-size, disabled/early-terminated, recursive, legacy, and one/two-phase deployment paths were traced. Distinct workers sharing an endpoint disable early release. Stream-load extraction omits the opt-in and retains conservative behavior.
  • Conditional checks: the batch marker, independent size gate, failure ordering, and recursive/endpoint exclusions have concrete failure-scenario comments matching the inspected control flow.
  • Test coverage: FE tests cover empty/recursive/duplicate-endpoint eligibility; BE tests cover ownership gates, missing/false opt-in, reset retention, callback EOF/errors, and reentrant erase/clear. Controlled concurrent service-boundary and multi-BE delayed-delivery execution remain validation limits.
  • Expected results: join rows (2,20) and (4,40), and recursive rows 1 through 4, match the supplied SQL and deterministic ordering. ProfileAction waits for COMPLETE and the suites use per-query tokens. Output-generation provenance was not independently reproduced.
  • Observability: existing query destruction logs, RPC error logs, and profile completion reporting expose the changed outcome; no additional metric requirement was substantiated.
  • Transactions and persistence: no EditLog, replay, transaction, or failover behavior is changed.
  • Writes and core data invariants: no write atomicity, partition visibility, or delete-bitmap behavior is changed. No introduced data-correctness defect was substantiated.
  • FE-to-BE propagation: the opt-in is emitted in shared parent RF parameters only after whole-query eligibility checks; BE requires both presence and true. Alternate send paths remain conservative.
  • Performance and memory: completion state is bounded per filter/round; the existing background worker scans retained contexts and eligible filters. Large filter payload ownership and cancellation teardown retain existing mechanisms. No new significant untracked allocation or hot-path regression was substantiated by source inspection.
  • Other risks and user focus: no additional user focus was supplied. Every initial risk was dismissed with source evidence; no unreviewed changed path or unresolved candidate remains.

Validation was static only. No builds, tests, benchmarks, formatting tools, or runtime checks were executed, and repository source was not modified. Runtime stress, multi-BE scheduling, mixed-version behavior, and author-reported test execution are not independently verified by this review.

Review converged after 2 round(s).

@mrhhsg

mrhhsg commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 28429 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 25d041404b28d1e58ef080fe4a73a3f8e8748a02, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17403	5150	5012	5012
q2	2126	306	245	245
q3	10168	1378	824	824
q4	4675	458	330	330
q5	7456	791	533	533
q6	175	184	148	148
q7	742	810	605	605
q8	9274	1350	1048	1048
q9	5565	4247	4318	4247
q10	6814	1297	1041	1041
q11	417	238	225	225
q12	646	395	272	272
q13	18135	3507	3059	3059
q14	273	262	242	242
q15	q16	739	719	678	678
q17	1194	772	579	579
q18	7045	6168	6131	6131
q19	1105	955	599	599
q20	382	338	226	226
q21	5152	2133	2279	2133
q22	354	292	252	252
Total cold run time: 99840 ms
Total hot run time: 28429 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5598	5579	5577	5577
q2	684	564	561	561
q3	5187	5374	4917	4917
q4	1969	2145	1533	1533
q5	5235	5172	5400	5172
q6	247	201	161	161
q7	2371	2036	1891	1891
q8	3045	2686	2729	2686
q9	8092	8025	8072	8025
q10	3734	3753	3278	3278
q11	602	434	419	419
q12	696	709	544	544
q13	3545	3830	3261	3261
q14	322	327	310	310
q15	q16	728	724	644	644
q17	8277	7076	6849	6849
q18	12930	12159	12844	12159
q19	942	780	773	773
q20	2135	2125	1940	1940
q21	5538	4546	4635	4546
q22	500	441	407	407
Total cold run time: 72377 ms
Total hot run time: 65653 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 153724 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 25d041404b28d1e58ef080fe4a73a3f8e8748a02, data reload: false

query5	4320	607	449	449
query6	444	211	195	195
query7	4812	446	227	227
query8	325	166	157	157
query9	8800	3236	3216	3216
query10	473	316	246	246
query11	5954	3857	3563	3563
query12	140	90	86	86
query13	1241	438	333	333
query14	6145	3921	3654	3654
query14_1	3470	3383	3439	3383
query15	211	207	185	185
query16	976	446	418	418
query17	849	671	534	534
query18	2408	409	300	300
query19	186	165	128	128
query20	82	79	76	76
query21	208	131	108	108
query22	12916	13040	12862	12862
query23	13456	12710	12479	12479
query23_1	12435	12586	12412	12412
query24	7324	838	483	483
query24_1	492	480	478	478
query25	516	396	334	334
query26	1252	258	136	136
query27	2784	440	273	273
query28	4600	2032	2029	2029
query29	1546	589	442	442
query30	293	213	186	186
query31	1000	921	818	818
query32	139	85	90	85
query33	522	310	232	232
query34	901	865	511	511
query35	723	751	648	648
query36	795	796	724	724
query37	123	97	76	76
query38	1791	1728	1657	1657
query39	777	793	748	748
query39_1	736	729	739	729
query40	223	112	96	96
query41	73	72	72	72
query42	89	83	82	82
query43	349	361	312	312
query44	1371	707	729	707
query45	189	180	168	168
query46	845	988	571	571
query47	2877	3031	2765	2765
query48	320	310	227	227
query49	591	396	297	297
query50	718	278	216	216
query51	10618	10630	10262	10262
query52	76	81	67	67
query53	188	227	151	151
query54	226	208	174	174
query55	75	71	63	63
query56	243	212	207	207
query57	1627	1625	1560	1560
query58	291	262	237	237
query59	2109	2158	2011	2011
query60	288	246	226	226
query61	146	146	148	146
query62	392	329	283	283
query63	191	172	154	154
query64	2740	930	775	775
query65	3333	3276	3255	3255
query66	1762	405	308	308
query67	22606	22650	22431	22431
query68	3028	1023	620	620
query69	393	275	251	251
query70	869	807	767	767
query71	284	233	210	210
query72	2826	2725	2485	2485
query73	533	540	302	302
query74	4633	4519	4364	4364
query75	2335	2310	1915	1915
query76	2285	1032	610	610
query77	369	385	272	272
query78	9809	9640	9179	9179
query79	1023	893	539	539
query80	923	462	383	383
query81	571	321	271	271
query82	566	136	115	115
query83	364	199	174	174
query84	302	121	107	107
query85	855	414	366	366
query86	361	238	233	233
query87	1984	1957	1811	1811
query88	3814	2782	2772	2772
query89	336	299	246	246
query90	1812	180	171	171
query91	159	151	129	129
query92	98	88	90	88
query93	1043	1018	573	573
query94	536	300	274	274
query95	572	383	299	299
query96	695	511	240	240
query97	2456	2441	2300	2300
query98	161	154	147	147
query99	773	767	664	664
Total cold run time: 237175 ms
Total hot run time: 153724 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.99 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 25d041404b28d1e58ef080fe4a73a3f8e8748a02, data reload: false

query1	0.00	0.00	0.01
query2	0.14	0.09	0.08
query3	0.33	0.13	0.13
query4	1.61	0.12	0.13
query5	0.27	0.26	0.25
query6	1.16	0.65	0.65
query7	0.04	0.00	0.01
query8	0.08	0.07	0.06
query9	0.47	0.37	0.35
query10	0.60	0.60	0.57
query11	0.34	0.18	0.19
query12	0.31	0.19	0.18
query13	0.52	0.50	0.52
query14	0.94	0.92	0.93
query15	0.65	0.59	0.57
query16	0.36	0.35	0.35
query17	1.06	1.04	1.06
query18	0.29	0.27	0.27
query19	1.95	1.80	1.91
query20	0.02	0.02	0.01
query21	15.41	0.34	0.29
query22	4.92	0.12	0.12
query23	15.88	0.47	0.28
query24	2.31	0.54	0.39
query25	0.16	0.11	0.09
query26	0.78	0.27	0.21
query27	0.10	0.10	0.10
query28	3.34	0.87	0.39
query29	12.60	4.34	3.34
query30	0.35	0.17	0.15
query31	2.76	0.58	0.32
query32	3.22	0.60	0.50
query33	2.95	3.02	3.09
query34	15.93	4.05	3.41
query35	3.38	3.37	3.34
query36	0.63	0.51	0.46
query37	0.12	0.10	0.10
query38	0.07	0.08	0.07
query39	0.06	0.06	0.07
query40	0.20	0.19	0.16
query41	0.10	0.06	0.05
query42	0.06	0.06	0.06
query43	0.07	0.06	0.05
Total cold run time: 96.54 s
Total hot run time: 24.99 s

### Background

The recursive runtime-filter regression checks that a repeated recursive join publishes a filter to the probe scan across an exchange.

### What problem does this PR solve?

Issue Number: None
Related PR: None
PR Type: Test

Problem Summary: The Cloud P0 planner does not render the recursive join with the exact PARTITIONED label required by the new test. Keep the join, runtime-filter target, exchange, and result checks while allowing a different join distribution label.

### Details

- **Failure:** Cloud P0 fails at the exact join-distribution assertion before checking runtime-filter behavior.
- **Cause:** The test assumes a physical distribution label that is not stable across deployment modes.
- **Stability evidence:** The isolated shared-nothing regression suite passes before and after this assertion change; Cloud validation remains pending.

### Testing

- `doris-local-regression run -d recursive_cte -s rf_merge_context_reuse` passed on the isolated local cluster.
- `git diff --check` passed.

### Release note

None.

### Check List (For Author)

- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Partially verified: Cloud P0 must validate the revised assertion.

### AI Disclosure

- Tool: OpenAI Codex
- Generated: Test assertion and commit description.
- Human review: Not applicable.
@mrhhsg

mrhhsg commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all 14 changed files at db176cf. No new actionable finding and no existing inline P0/P1 finding to carry forward. The static review converged in one round: both complete-review agents and the separate concurrency/lifetime reviewer returned NO_NEW_VALUABLE_FINDINGS, and every initial risk was dismissed with source evidence.

Critical checkpoint conclusions:

  • Goal and tests: the change permits final profile reporting by releasing the extra RF merge QueryContext owner after complete eligible deployment and required remote completion. Added ownership, callback, eligibility, profile-deadline and recursive tests address that goal; they were inspected, not executed.
  • Scope and reuse: changes are focused on eligibility and completion accounting, reusing the existing cancel worker, BRPC error handling and profile reporting.
  • Concurrency and locks: service preparation, pipeline tasks, RPC workers, BRPC callbacks and the cleaner are the concurrent actors. Release/acquire dispatch gates follow all send-loop increments; failure is published before the last callback decrement. Controller checks and final owner destruction occur outside map shard locks. No introduced lock inversion or blocking wait was substantiated.
  • Lifecycle and static initialization: live fragment and incoming RPC references retain QueryContext after its extra owner is removed. Callbacks hold weak query ownership and a captured per-round Completion; AutoReleaseClosure retains the callback during invocation. Relay RPC state has independent ownership. No new strong cycle or static-initialization dependency was found.
  • Configuration: none added; cleanup uses the existing cancel-worker interval.
  • Interface compatibility: missing/false opt-in keeps conservative lifetime, and old BE ignores the optional field. No disk-format or exported ABI change was identified; mixed-version execution was not run.
  • Thrift IDs: complete TRuntimeFilterParams definitions were compared on HEAD and live-verified branch-3.1, branch-4.0, branch-4.1 and branch-4.2. New optional bool field 6 is unused on each release branch; existing meanings are preserved. This PR targets master.
  • Parallel paths: local-only, remote direct/tree, broadcast, runtime-size, disabled/early-terminated, recursive, legacy and one/two-phase deployment paths were checked. Duplicate worker identities at one endpoint disable release. Alternate stream-load serialization does not carry the opt-in and remains conservative; cloud and shared-nothing use the same relevant lifecycle.
  • Special conditions: comments explain the complete-batch barrier, separate size phase, Bloom/nonbroadcast requirement, local-only bypass and query-wide recursive/endpoint exclusions. These match the inspected call chains.
  • Test coverage: BE tests cover ownership gates, missing/false opt-in, old Completion lifetime, EOF/error/transport outcomes and reentrant erase/clear; FE tests cover empty/recursive plans and endpoint identity. Real RPC timing and multi-BE interleavings remain execution-validation limits.
  • Expected outputs: ordered join rows (2,20),(4,40) and recursive rows 1 through 4 agree with supplied SQL. Profile tests use unique SQL tokens and require COMPLETE within ten seconds. Output generation was not independently reproduced.
  • Observability: existing RPC failure logs, query destruction logs and final profile reporting expose relevant outcomes; no additional necessary metric was identified.
  • Transactions and persistence: no EditLog, replay, failover or transaction behavior changes.
  • Data writes and core invariants: no write atomicity, visible-version or delete-bitmap behavior changes; no introduced data-correctness defect was substantiated.
  • FE-to-BE propagation: full-query eligibility is serialized in parent RF parameters; BE requires presence and true. Other send paths stay conservative.
  • Performance and memory: completion state is constant-sized per filter/round, with accounting per dispatched RPC and a linear scan on the existing worker. No significant new untracked allocation, payload copy or hot-path regression was substantiated by source inspection.
  • Other risks and user focus: no additional user focus was supplied. Recursive mutable dispatch/reset interactions were checked against merge-base source and predate this PR; the new cleanup excludes recursive plans. No unresolved introduced-code candidate or unreviewed changed path remains.

Validation was static only. No builds, tests, benchmarks, formatting tools or runtime checks were run, and repository source was not modified. Multi-BE delayed filters, controlled duplicate-start/concurrent-reset scheduling, mixed-version execution and author-reported validation were not independently reproduced.

Review converged after 1 round(s).

@mrhhsg

mrhhsg commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.65% (2101/2741)
Line Coverage 65.98% (38776/58772)
Region Coverage 53.71% (36383/67743)
Branch Coverage 57.22% (11858/20722)

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 28282 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit db176cfd398016017508485a1c18a11af7007c66, data reload: false

------ Round 1 ----------------------------------
============================================
q1	16603	5147	5043	5043
q2	2123	302	248	248
q3	9900	1375	816	816
q4	4559	458	329	329
q5	7315	798	534	534
q6	182	189	155	155
q7	740	790	598	598
q8	9281	1331	1041	1041
q9	5482	4155	4164	4155
q10	6818	1298	1033	1033
q11	430	243	231	231
q12	638	404	277	277
q13	17932	3598	2972	2972
q14	275	266	251	251
q15	q16	721	714	676	676
q17	1201	742	579	579
q18	6985	6193	6121	6121
q19	1113	946	607	607
q20	392	335	223	223
q21	5078	2139	2303	2139
q22	344	293	254	254
Total cold run time: 98112 ms
Total hot run time: 28282 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5601	5564	5592	5564
q2	653	587	518	518
q3	5193	5321	4933	4933
q4	1978	2164	1527	1527
q5	5279	5160	5185	5160
q6	234	187	141	141
q7	2596	2104	1812	1812
q8	3086	2651	2668	2651
q9	8022	8045	7889	7889
q10	3694	3650	3272	3272
q11	692	465	396	396
q12	689	711	528	528
q13	3487	3824	3294	3294
q14	316	317	296	296
q15	q16	703	717	661	661
q17	8342	7065	6821	6821
q18	12975	12217	12874	12217
q19	907	793	787	787
q20	2150	2134	1909	1909
q21	5599	4568	4658	4568
q22	516	472	433	433
Total cold run time: 72712 ms
Total hot run time: 65377 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 153734 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit db176cfd398016017508485a1c18a11af7007c66, data reload: false

query5	4304	585	443	443
query6	429	217	190	190
query7	4805	441	233	233
query8	322	162	153	153
query9	8738	3210	3211	3210
query10	473	321	253	253
query11	5975	3861	3594	3594
query12	146	91	84	84
query13	1248	465	326	326
query14	6097	3911	3660	3660
query14_1	3381	3455	3421	3421
query15	205	197	171	171
query16	945	435	409	409
query17	866	664	508	508
query18	2405	405	290	290
query19	184	157	129	129
query20	80	89	83	83
query21	213	121	104	104
query22	12975	12907	12849	12849
query23	13343	12800	12380	12380
query23_1	12447	12898	12476	12476
query24	7200	823	458	458
query24_1	479	477	481	477
query25	523	426	371	371
query26	1258	263	145	145
query27	2765	433	281	281
query28	4538	2059	2040	2040
query29	1534	618	468	468
query30	293	221	180	180
query31	1003	974	805	805
query32	140	93	93	93
query33	535	314	245	245
query34	914	841	512	512
query35	736	745	651	651
query36	802	821	736	736
query37	129	103	87	87
query38	1769	1762	1666	1666
query39	795	798	759	759
query39_1	734	741	736	736
query40	228	122	99	99
query41	75	71	71	71
query42	86	84	82	82
query43	355	361	316	316
query44	1303	697	702	697
query45	183	183	166	166
query46	836	955	570	570
query47	2723	2901	2939	2901
query48	316	316	223	223
query49	584	419	301	301
query50	681	275	213	213
query51	10701	10384	10357	10357
query52	82	82	74	74
query53	189	213	160	160
query54	246	201	197	197
query55	76	70	69	69
query56	248	238	229	229
query57	1647	1553	1596	1553
query58	299	267	262	262
query59	2144	2160	2012	2012
query60	295	252	258	252
query61	174	167	169	167
query62	393	338	295	295
query63	191	163	160	160
query64	2835	1010	776	776
query65	3326	3270	3260	3260
query66	1757	411	292	292
query67	22666	22609	22491	22491
query68	3039	1004	619	619
query69	385	301	237	237
query70	853	770	762	762
query71	298	242	211	211
query72	2695	2602	2365	2365
query73	510	521	296	296
query74	4612	4528	4334	4334
query75	2352	2263	1878	1878
query76	2152	1004	589	589
query77	342	365	269	269
query78	9691	9679	9073	9073
query79	995	904	537	537
query80	533	432	355	355
query81	527	317	266	266
query82	554	133	107	107
query83	311	197	184	184
query84	314	119	98	98
query85	798	424	370	370
query86	321	233	228	228
query87	1959	1942	1799	1799
query88	3777	2757	2750	2750
query89	330	279	249	249
query90	1860	163	155	155
query91	167	157	131	131
query92	107	88	87	87
query93	1008	1017	581	581
query94	436	310	283	283
query95	596	386	302	302
query96	674	486	244	244
query97	2447	2427	2300	2300
query98	158	149	145	145
query99	774	756	646	646
Total cold run time: 235664 ms
Total hot run time: 153734 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit db176cfd398016017508485a1c18a11af7007c66, data reload: false

query1	0.01	0.01	0.01
query2	0.14	0.08	0.08
query3	0.34	0.13	0.13
query4	1.61	0.13	0.13
query5	0.26	0.24	0.25
query6	1.15	0.64	0.64
query7	0.04	0.00	0.00
query8	0.09	0.07	0.07
query9	0.46	0.35	0.35
query10	0.58	0.59	0.62
query11	0.31	0.18	0.17
query12	0.31	0.18	0.18
query13	0.50	0.52	0.51
query14	0.93	0.92	0.92
query15	0.66	0.58	0.59
query16	0.35	0.37	0.35
query17	1.02	1.01	1.01
query18	0.27	0.26	0.26
query19	1.95	1.86	1.84
query20	0.02	0.01	0.02
query21	15.40	0.33	0.29
query22	4.89	0.12	0.12
query23	15.90	0.49	0.29
query24	2.32	0.51	0.38
query25	0.15	0.09	0.10
query26	0.76	0.28	0.21
query27	0.10	0.10	0.11
query28	3.45	0.85	0.38
query29	12.63	4.29	3.33
query30	0.36	0.17	0.14
query31	2.76	0.59	0.34
query32	3.25	0.61	0.49
query33	2.94	2.98	2.98
query34	15.94	4.07	3.41
query35	3.39	3.35	3.34
query36	0.60	0.50	0.49
query37	0.12	0.10	0.10
query38	0.08	0.07	0.07
query39	0.06	0.06	0.06
query40	0.18	0.16	0.17
query41	0.10	0.05	0.05
query42	0.06	0.06	0.05
query43	0.06	0.06	0.06
Total cold run time: 96.5 s
Total hot run time: 25 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 33.33% (3/9) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 67.45% (32198/47738)
Line Coverage 52.29% (339032/648330)
Region Coverage 47.78% (275432/576474)
Branch Coverage 49.63% (129938/261800)

### Background

The RF merge profile regression checks that local and shuffled joins produce complete query profiles.

### What problem does this PR solve?

Issue Number: None
Related PR: apache#70305 (updates its regression coverage)
PR Type: Test

Problem Summary: The profile suite assumed every shuffled join uses a PARTITIONED join label. Cluster planning can select another distribution while still retaining the join, Exchange, and runtime filter behavior under test. Check those relevant plan properties without requiring one distribution label.

### Details

- **Failure:** The profile suite failed on its exact PARTITIONED join assertion.
- **Cause:** The assertion depended on a physical distribution choice rather than the behavior this suite verifies.
- **Stability evidence:** The focused suite passed three consecutive runs on a local ASAN cluster after the change; CI must validate the alternate cluster plan.

### Testing

- `doris-local-regression run -d query_profile -s rf_merge_context_profile` (three consecutive local ASAN runs, passed).
- `git diff --check` (passed).

### Release note

None.

### Check List (For Author)

- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Partially verified: the local focused suite passed; CI must verify the alternate cluster plan.

### AI Disclosure

- Tool: Codex
- Generated: Regression assertion update and this description.
- Human review: Not applicable.
@mrhhsg

mrhhsg commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

/review

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.

2 participants