Skip to content

[fix](binlog) Commit table stream offsets for empty inserts - #67126

Open
luwei16 wants to merge 1 commit into
apache:masterfrom
luwei16:fix/doris-28064-empty-stream-offset
Open

[fix](binlog) Commit table stream offsets for empty inserts#67126
luwei16 wants to merge 1 commit into
apache:masterfrom
luwei16:fix/doris-28064-empty-stream-offset

Conversation

@luwei16

@luwei16 luwei16 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #66273

Related PR: None

Problem Summary: When the optimizer reduces an INSERT INTO SELECT from a Table Stream to an empty relation, the previous empty-insert shortcut bypasses the transaction lifecycle. The target receives zero rows, but the stream offset is not committed, so the same stream state can be read repeatedly. Keep empty Table Stream reads in the transaction lifecycle, skip coordinator data execution, and commit the offset atomically. Ordinary empty inserts continue to use the existing fast-return path.

Release note

Table Stream offsets now advance when INSERT INTO SELECT succeeds with zero rows.

Check List (For Author)

  • Test: Unit Test
    • InsertIntoTableCommandTableStreamTest and OlapInsertExecutorTest (21 tests)
    • ./build.sh --fe -j 192
  • Behavior changed: Yes (successful zero-row Table Stream inserts now commit offsets; ordinary inserts are unchanged)
  • Does this need documentation: No

### What problem does this PR solve?

Issue Number: close apache#66273

Related PR: None

Problem Summary: When the optimizer reduces an INSERT INTO SELECT from a Table Stream to an empty relation, the previous empty-insert shortcut bypasses the transaction lifecycle. The target receives zero rows, but the stream offset is not committed, so the same stream state can be read repeatedly. Keep empty Table Stream reads in the transaction lifecycle, skip coordinator data execution, and commit the offset atomically. Ordinary empty inserts continue to use the existing fast-return path.

### Release note

Table Stream offsets now advance when INSERT INTO SELECT succeeds with zero rows.

### Check List (For Author)

- Test: Unit Test
    - InsertIntoTableCommandTableStreamTest and OlapInsertExecutorTest (21 tests)
    - ./build.sh --fe -j 192
- Behavior changed: Yes (successful zero-row Table Stream inserts now commit offsets; ordinary inserts are unchanged)
- Does this need documentation: No
@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?

@luwei16

luwei16 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@luwei16 luwei16 changed the title [fix](fe) Commit table stream offsets for empty inserts [fix](binlog) Commit table stream offsets for empty inserts Aug 25, 2026
@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 100.00% (5/5) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17567	3012	3003	3003
q2	2070	244	219	219
q3	10262	868	516	516
q4	4673	243	198	198
q5	7684	558	386	386
q6	142	114	95	95
q7	537	510	381	381
q8	9242	904	896	896
q9	3440	2394	2406	2394
q10	6486	856	705	705
q11	393	199	176	176
q12	605	258	191	191
q13	18185	1533	1164	1164
q14	158	163	140	140
q15	q16	427	398	367	367
q17	1331	829	789	789
q18	3041	2217	2217	2217
q19	1130	931	807	807
q20	385	270	205	205
q21	5284	1746	1836	1746
q22	326	259	219	219
Total cold run time: 93368 ms
Total hot run time: 16814 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3362	3303	3297	3297
q2	502	392	359	359
q3	2194	2331	2138	2138
q4	1184	1149	888	888
q5	2182	2130	2103	2103
q6	172	124	85	85
q7	1011	908	884	884
q8	1607	1401	1404	1401
q9	3142	3093	3068	3068
q10	1869	1806	1626	1626
q11	349	269	248	248
q12	448	428	344	344
q13	1483	1547	1145	1145
q14	172	173	158	158
q15	q16	390	392	353	353
q17	3594	3369	3273	3273
q18	4860	4421	4772	4421
q19	1024	811	952	811
q20	1009	953	828	828
q21	3718	3065	3187	3065
q22	404	331	308	308
Total cold run time: 34676 ms
Total hot run time: 30803 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81622 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 494c425766deaa75c2e6627bb331f7309416a352, data reload: false

query5	4277	406	342	342
query6	391	152	120	120
query7	4935	404	230	230
query8	290	127	115	115
query9	8688	2873	2863	2863
query10	398	215	189	189
query11	5391	1049	907	907
query12	127	75	69	69
query13	1199	468	329	329
query14	6171	2178	2046	2046
query14_1	1952	1932	1933	1932
query15	197	113	107	107
query16	906	352	335	335
query17	792	423	330	330
query18	2327	317	219	219
query19	156	129	99	99
query20	68	70	68	68
query21	198	98	85	85
query22	5381	5237	5289	5237
query23	6728	6120	6009	6009
query23_1	6012	5969	6076	5969
query24	7335	1089	733	733
query24_1	764	771	761	761
query25	411	283	243	243
query26	1236	238	132	132
query27	2780	379	248	248
query28	4742	1493	1496	1493
query29	905	455	337	337
query30	253	162	128	128
query31	813	390	322	322
query32	126	70	70	70
query33	444	210	164	164
query34	971	799	481	481
query35	401	389	332	332
query36	574	586	512	512
query37	118	78	65	65
query38	988	842	791	791
query39	477	489	492	489
query39_1	478	469	469	469
query40	197	86	78	78
query41	51	48	48	48
query42	70	74	72	72
query43	236	236	211	211
query44	1009	537	543	537
query45	108	114	97	97
query46	761	900	529	529
query47	756	730	688	688
query48	316	311	233	233
query49	544	231	181	181
query50	743	261	193	193
query51	8058	8062	8017	8017
query52	70	67	59	59
query53	187	210	147	147
query54	227	174	161	161
query55	72	68	53	53
query56	196	157	158	157
query57	678	684	706	684
query58	207	162	155	155
query59	1201	1222	1079	1079
query60	241	205	175	175
query61	135	143	136	136
query62	361	216	185	185
query63	179	143	151	143
query64	2855	801	687	687
query65	1610	1594	1555	1555
query66	1883	269	225	225
query67	10229	9633	9761	9633
query68	2738	1221	736	736
query69	332	202	185	185
query70	679	605	614	605
query71	259	173	160	160
query72	2317	1735	1557	1557
query73	650	602	342	342
query74	1571	1223	1117	1117
query75	1177	1099	947	947
query76	2278	740	587	587
query77	262	265	197	197
query78	3855	3730	3253	3253
query79	2570	813	586	586
query80	1637	336	274	274
query81	488	155	129	129
query82	622	143	97	97
query83	282	217	191	191
query84	291	111	90	90
query85	785	352	303	303
query86	385	170	164	164
query87	1006	959	891	891
query88	2763	2105	2088	2088
query89	293	195	173	173
query90	1979	127	128	127
query91	130	117	100	100
query92	79	62	71	62
query93	1510	1059	683	683
query94	631	245	227	227
query95	522	242	292	242
query96	780	568	275	275
query97	1089	1067	1053	1053
query98	166	134	138	134
query99	424	343	312	312
Total cold run time: 177535 ms
Total hot run time: 81622 ms

@hello-stephen

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

query1	0.01	0.00	0.00
query2	0.08	0.04	0.04
query3	0.24	0.12	0.11
query4	1.60	0.09	0.10
query5	0.18	0.17	0.15
query6	1.26	0.67	0.74
query7	0.03	0.00	0.01
query8	0.04	0.03	0.03
query9	0.29	0.22	0.21
query10	0.35	0.35	0.34
query11	0.16	0.11	0.12
query12	0.15	0.13	0.12
query13	0.30	0.30	0.30
query14	0.48	0.46	0.45
query15	0.36	0.36	0.34
query16	0.21	0.22	0.24
query17	0.66	0.67	0.66
query18	0.18	0.17	0.17
query19	1.20	1.16	1.20
query20	0.01	0.01	0.01
query21	15.44	0.15	0.13
query22	5.06	0.04	0.04
query23	16.19	0.26	0.10
query24	2.99	0.32	0.26
query25	0.13	0.03	0.03
query26	0.76	0.17	0.12
query27	0.04	0.03	0.03
query28	3.63	0.59	0.26
query29	12.44	3.14	2.56
query30	0.24	0.11	0.13
query31	2.75	0.38	0.17
query32	3.51	0.33	0.26
query33	1.59	1.55	1.79
query34	15.42	2.22	1.81
query35	1.76	1.72	1.70
query36	0.44	0.28	0.28
query37	0.06	0.03	0.03
query38	0.04	0.03	0.02
query39	0.04	0.03	0.02
query40	0.12	0.07	0.08
query41	0.07	0.02	0.03
query42	0.03	0.02	0.02
query43	0.03	0.02	0.03
Total cold run time: 90.57 s
Total hot run time: 14.79 s

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.

[stream] Empty INSERT SELECT does not advance table stream offset

2 participants