Skip to content

[fix](exec) publish copied local exchange rows#63547

Open
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:publish-copied-local-exchange
Open

[fix](exec) publish copied local exchange rows#63547
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:publish-copied-local-exchange

Conversation

@Mryange
Copy link
Copy Markdown
Contributor

@Mryange Mryange commented May 22, 2026

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Local exchange copy-on-read paths copy row slices into a MutableBlock, but the copied columns were not published back to the output Block. When output columns are shared and copy-on-write creates new mutable columns, the source side can return the old empty block and lose rows. This change publishes copied rows back to the output block and adds a BE unit test for the shared-output-column case.

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 22, 2026

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

I found one blocking test-coverage gap. The implementation is focused and the added to_block() handoff appears correct for the reviewed COW/mem-reuse failure, but the PR changes three exchanger implementations and only proves one of them.

Critical checkpoint conclusions:

  • Goal and proof: the goal is to return copied rows after MutableBlock mutates/reuses an output block with shared columns. The code addresses this in adaptive, shuffle, and broadcast paths, but tests currently prove only the adaptive path.
  • Scope: the implementation is small and localized.
  • Concurrency/lifecycle: no new concurrency, locks, dependencies, atomics, or lifecycle ownership changes were introduced. Existing queue/dependency behavior is unchanged.
  • Config/compatibility/protocol: no new configs, storage/protocol formats, or compatibility concerns.
  • Parallel paths: this is the main issue; ShuffleExchanger and BroadcastExchanger are parallel changed paths and need equivalent coverage.
  • Error handling/memory safety: existing RETURN_IF_ERROR behavior is preserved; no new untracked long-lived memory ownership was introduced.
  • Transaction/data visibility: not applicable.
  • Observability/performance: no new observability need identified; extra to_block() is only after copied rows are materialized and is consistent with the fix.

User focus: no additional user-provided review focus was supplied.

block, partitioned_block.first->_data_block);
RETURN_IF_ERROR(get_data());
if (mutable_block.rows() > 0) {
*block = mutable_block.to_block();
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.

This same MutableBlock handoff fix is applied to ShuffleExchanger here and to BroadcastExchanger below, but the new regression test only exercises AdaptivePassthroughExchanger. The failure mode depends on build_mutable_mem_reuse_block() mutating an output block whose column is shared, so existing tests that call these exchangers with a fresh Block would not catch a regression in the shuffle or broadcast paths. Please add equivalent shared-output-column coverage for the changed shuffle and broadcast get_block() paths, or otherwise prove these two paths are covered by an existing test.

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 22, 2026

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

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

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17649	3912	3915	3912
q2	q3	10868	1324	793	793
q4	4687	478	344	344
q5	7553	2320	2096	2096
q6	233	177	135	135
q7	942	763	639	639
q8	9360	1674	1524	1524
q9	5157	4892	4895	4892
q10	6372	2086	1781	1781
q11	431	270	248	248
q12	626	429	306	306
q13	18097	3358	2778	2778
q14	268	256	233	233
q15	q16	817	778	701	701
q17	960	909	999	909
q18	6782	5868	5561	5561
q19	1292	1172	1107	1107
q20	515	402	266	266
q21	6013	2586	2423	2423
q22	438	356	305	305
Total cold run time: 99060 ms
Total hot run time: 30953 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4185	4103	4099	4099
q2	q3	4485	4962	4304	4304
q4	2077	2208	1379	1379
q5	4335	4213	4252	4213
q6	226	171	129	129
q7	1741	1951	1830	1830
q8	2561	2139	2156	2139
q9	7984	8058	7782	7782
q10	4497	4500	4046	4046
q11	575	399	390	390
q12	727	727	534	534
q13	3268	3629	2982	2982
q14	306	311	270	270
q15	q16	711	729	655	655
q17	1341	1277	1302	1277
q18	8159	7194	7365	7194
q19	1161	1132	1144	1132
q20	2217	2201	1944	1944
q21	5282	4585	4468	4468
q22	542	456	396	396
Total cold run time: 56380 ms
Total hot run time: 51163 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 170006 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 ecbfda56fc24d21f4f217c7d015d1226e7f0c9cd, data reload: false

query5	4336	640	512	512
query6	357	218	205	205
query7	4287	556	296	296
query8	324	226	225	225
query9	8836	3947	3951	3947
query10	479	336	299	299
query11	5814	2371	2181	2181
query12	183	128	125	125
query13	1271	642	437	437
query14	6046	5336	5053	5053
query14_1	4383	4371	4347	4347
query15	213	205	183	183
query16	992	478	432	432
query17	968	746	613	613
query18	2464	498	369	369
query19	222	207	164	164
query20	140	133	132	132
query21	211	140	118	118
query22	13534	13609	13531	13531
query23	17295	16312	15959	15959
query23_1	16129	16125	16190	16125
query24	7556	1746	1317	1317
query24_1	1286	1299	1365	1299
query25	567	502	439	439
query26	1307	318	179	179
query27	2682	563	359	359
query28	4468	1956	1945	1945
query29	995	619	516	516
query30	311	246	201	201
query31	1125	1085	946	946
query32	97	79	74	74
query33	553	368	306	306
query34	1188	1102	641	641
query35	755	825	664	664
query36	1292	1354	1200	1200
query37	151	101	89	89
query38	3179	3143	3051	3051
query39	945	951	887	887
query39_1	859	867	880	867
query40	235	146	127	127
query41	66	63	65	63
query42	110	110	110	110
query43	318	322	282	282
query44	
query45	205	200	190	190
query46	1105	1183	741	741
query47	2304	2328	2229	2229
query48	405	373	298	298
query49	637	492	378	378
query50	1024	340	246	246
query51	4246	4262	4164	4164
query52	103	106	93	93
query53	243	276	195	195
query54	300	284	258	258
query55	92	91	83	83
query56	307	298	287	287
query57	1400	1418	1310	1310
query58	295	272	256	256
query59	1581	1628	1414	1414
query60	319	318	316	316
query61	162	158	160	158
query62	669	626	571	571
query63	239	195	203	195
query64	2413	796	642	642
query65	
query66	1731	483	346	346
query67	30040	30085	29807	29807
query68	
query69	461	338	305	305
query70	1001	995	1003	995
query71	290	312	260	260
query72	3017	2657	2416	2416
query73	832	740	412	412
query74	5067	4897	4734	4734
query75	2682	2604	2250	2250
query76	2316	1117	747	747
query77	392	410	332	332
query78	12164	12181	11559	11559
query79	1466	1047	725	725
query80	1333	527	446	446
query81	524	285	259	259
query82	1009	156	120	120
query83	354	266	244	244
query84	311	138	117	117
query85	944	551	461	461
query86	465	329	329	329
query87	3407	3369	3206	3206
query88	3506	2667	2634	2634
query89	445	384	335	335
query90	1908	193	181	181
query91	177	165	139	139
query92	85	78	70	70
query93	1637	1417	915	915
query94	723	363	304	304
query95	688	467	345	345
query96	1093	780	350	350
query97	2700	2694	2545	2545
query98	233	226	220	220
query99	1116	1123	1003	1003
Total cold run time: 253687 ms
Total hot run time: 170006 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 100.00% (9/9) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.66% (20764/38697)
Line Coverage 37.26% (196682/527901)
Region Coverage 33.59% (154187/458987)
Branch Coverage 34.59% (67147/194144)

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (9/9) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 72.05% (27310/37903)
Line Coverage 55.40% (291703/526555)
Region Coverage 52.53% (243440/463416)
Branch Coverage 53.81% (104854/194871)

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