Skip to content

[fix](rowset) Keep the real error and drop failed writers in the rowset write path#66048

Open
airborne12 wants to merge 4 commits into
apache:masterfrom
airborne12:fix-rowset-writer-close-error-propagation
Open

[fix](rowset) Keep the real error and drop failed writers in the rowset write path#66048
airborne12 wants to merge 4 commits into
apache:masterfrom
airborne12:fix-rowset-writer-close-error-propagation

Conversation

@airborne12

@airborne12 airborne12 commented Jul 25, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary:

Failures in the rowset write path were not handled consistently:

  1. A failed SegmentCreator write could leave a failed writer reusable. A failed add_block()
    or flush() did not always discard the writer or preserve the failure. A later operation could
    continue with invalid state or hide the original error.

  2. File cleanup stopped at the first error. Segment and inverted-index writer collections used
    early returns while closing multiple files. Once one writer failed, later writers could remain
    open. Segcompaction output writers could also remain open after a fatal compaction error or a
    delete-bitmap failure.

  3. Segcompaction lost the original error. _segcompaction_status stored only an integer error
    code and reconstructed a generic SEGCOMPACTION_FAILED, discarding the original status code and
    message.

  4. Segment index cache preload was coupled to writer finalization and could run too early. It
    could be triggered before every segment and inverted-index file had closed successfully, or
    after an earlier write had already failed.

This PR makes SegmentCreator terminal after the first write failure and keeps returning that
original status. It attempts to close all segment, inverted-index, and segcompaction output writers
while returning the first error. Segcompaction now preserves its full Status. Segment index cache
preload is centralized in the existing loader module and runs only after all writes and file closes
succeed; disabled and local-rowset paths do not enqueue tasks. Rowsets without inverted indexes
still preload segment-internal index ranges such as short-key and footer data.

Release note

Fix rowset writer failure handling by preserving the original error, terminating a failed
SegmentCreator, closing all related file writers, and preloading segment indexes only after every
write and file close succeeds.

Check List (For Author)

  • Test

    • Regression test

    • Unit Test

      13 targeted ASAN BE unit tests cover:

      • closing all segment and inverted-index writers while returning the first error;
      • terminating SegmentCreator, preserving its first write error, and skipping preload after
        write or close failure;
      • preserving fatal segcompaction status and closing compaction output writers;
      • index-only cache preload for load and vertical compaction, including no-inverted-index,
        disabled, local-rowset, and final-flush-failure paths.
    • 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.

      The first rowset write or close error is preserved, cleanup continues for all related writers,
      and segment index cache preload is skipped unless all writes and closes succeed. Callers may
      now receive a more specific status instead of SEGCOMPACTION_FAILED.

  • Does this need documentation?

    • No.

Check List (For Reviewer who merge this PR)

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

…et write path

Three places lose information or state when a write fails.

SegmentCreator::flush() reset _flush_writer only on success:

    RETURN_IF_ERROR(_flush_writer->flush());
    _flush_writer.reset();
    return Status::OK();

so after a failed flush the creator still holds the writer that just failed. add_block() had the same
shape -- a failed add_rows returned without discarding the writer, and the next call kept feeding
the broken one. Both now capture the status, drop the writer, and return the error.

SegmentFileCollection::close() used RETURN_IF_ERROR inside its loop, so a writer that failed to
close left every later writer unclosed. It now closes all of them and returns the first error.

_segcompaction_status was a std::atomic<int> holding only an error code, and each reader rebuilt a
fresh Status::Error<SEGCOMPACTION_FAILED>("... meet invalid state, error code: {}") from it, so the
original message and any more specific code were gone before the caller saw them. It is now an
AtomicStatus, which already exists in be/src/common/status.h, and the stored status is returned
as-is.

The two new tests drive the real failures rather than the refactor: one makes an early writer fail
to close and checks the later ones were still closed, the other injects a failure into
SegmentFlusher::_add_rows through a new TEST_SYNC_POINT and checks the creator allocates a fresh
segment instead of reusing the failed one.
@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?

@airborne12

Copy link
Copy Markdown
Member Author

run buildall

airborne12 added a commit to airborne12/apache-doris that referenced this pull request Jul 25, 2026
…ange

The rowset write path fixes bundled here are not SNII: a failed SegmentCreator flush or add left the
broken writer in place, SegmentFileCollection::close stopped at the first writer that failed to
close, and segcompaction reported a generic SEGCOMPACTION_FAILED instead of its real status. No SNII
or CommonGrams code calls any of it.

They now live in apache#66048 against master, with the two failure-path tests that cover them.
The six production files and segment_writer_mow_check_test.cpp go back to master here.

row_ranges.h keeps is_empty() const -- that one looked like an unrelated tidy-up but
segment_iterator.cpp calls it through a const RowRanges, so SNII needs it.
@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17671	4254	4116	4116
q2	2086	328	201	201
q3	10206	1539	890	890
q4	4713	515	346	346
q5	7692	849	576	576
q6	202	178	140	140
q7	800	843	611	611
q8	9985	1669	1640	1640
q9	6030	4366	4331	4331
q10	6845	1773	1470	1470
q11	521	361	324	324
q12	760	611	452	452
q13	18089	3425	2711	2711
q14	279	276	250	250
q15	q16	800	784	719	719
q17	918	1036	893	893
q18	7096	5902	5634	5634
q19	1454	1232	1018	1018
q20	774	705	624	624
q21	5843	2743	2436	2436
q22	432	360	294	294
Total cold run time: 103196 ms
Total hot run time: 29676 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4604	4507	4504	4504
q2	323	352	214	214
q3	4827	5098	4454	4454
q4	2316	2368	1373	1373
q5	4692	4483	4913	4483
q6	280	213	147	147
q7	2165	1870	1601	1601
q8	2768	2352	2304	2304
q9	8106	8021	8014	8014
q10	4970	4981	4302	4302
q11	632	466	395	395
q12	869	826	560	560
q13	3461	3967	3009	3009
q14	313	333	291	291
q15	q16	765	788	682	682
q17	1429	1392	1414	1392
q18	8478	7267	7064	7064
q19	1102	1057	1080	1057
q20	2249	2239	1927	1927
q21	5642	4844	4657	4657
q22	557	457	406	406
Total cold run time: 60548 ms
Total hot run time: 52836 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 177502 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 6a95927e5635ec701bf22023febfb273391b0acd, data reload: false

query5	4313	623	491	491
query6	470	226	207	207
query7	4847	622	336	336
query8	331	187	167	167
query9	8751	4042	4064	4042
query10	475	351	325	325
query11	5803	2364	2127	2127
query12	157	101	98	98
query13	1231	599	420	420
query14	6231	5193	4841	4841
query14_1	4228	4221	4241	4221
query15	214	197	174	174
query16	1020	469	447	447
query17	918	688	555	555
query18	2462	472	367	367
query19	213	188	152	152
query20	113	116	109	109
query21	233	162	139	139
query22	13587	13581	13326	13326
query23	17392	16569	16125	16125
query23_1	16271	16287	16163	16163
query24	7501	1758	1260	1260
query24_1	1340	1270	1272	1270
query25	552	443	366	366
query26	1326	386	208	208
query27	2575	630	387	387
query28	4471	1976	1942	1942
query29	1068	587	452	452
query30	334	250	224	224
query31	1120	1086	964	964
query32	108	57	59	57
query33	504	323	249	249
query34	1162	1138	640	640
query35	760	767	667	667
query36	1189	1172	1068	1068
query37	159	107	91	91
query38	1859	1689	1646	1646
query39	884	864	857	857
query39_1	823	834	838	834
query40	259	167	144	144
query41	66	63	67	63
query42	92	90	89	89
query43	310	314	279	279
query44	1395	748	742	742
query45	192	183	171	171
query46	1091	1175	719	719
query47	2173	2113	2044	2044
query48	398	393	277	277
query49	592	418	310	310
query50	1130	420	337	337
query51	11013	11034	10809	10809
query52	86	98	73	73
query53	257	279	202	202
query54	312	246	238	238
query55	76	73	69	69
query56	330	315	293	293
query57	1327	1288	1257	1257
query58	305	275	263	263
query59	1597	1647	1437	1437
query60	342	288	282	282
query61	178	170	173	170
query62	554	495	455	455
query63	249	211	206	206
query64	2979	1139	961	961
query65	4777	4632	4672	4632
query66	1911	522	406	406
query67	29239	28770	29224	28770
query68	3114	1474	921	921
query69	410	300	274	274
query70	1038	979	984	979
query71	438	338	311	311
query72	3040	2644	2353	2353
query73	832	767	410	410
query74	5078	4951	4695	4695
query75	2534	2510	2135	2135
query76	2321	1169	777	777
query77	357	367	284	284
query78	11855	11892	11368	11368
query79	1426	1217	806	806
query80	1310	560	454	454
query81	512	340	290	290
query82	602	157	124	124
query83	375	323	302	302
query84	318	156	128	128
query85	959	589	504	504
query86	443	298	285	285
query87	1826	1825	1755	1755
query88	3693	2762	2770	2762
query89	436	370	321	321
query90	1968	213	193	193
query91	203	194	162	162
query92	62	60	56	56
query93	1656	1592	1041	1041
query94	735	356	315	315
query95	784	479	569	479
query96	1036	786	350	350
query97	2622	2618	2489	2489
query98	214	202	204	202
query99	1095	1120	974	974
Total cold run time: 263942 ms
Total hot run time: 177502 ms

@hello-stephen

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

query1	0.01	0.01	0.00
query2	0.09	0.05	0.05
query3	0.25	0.15	0.12
query4	1.61	0.14	0.12
query5	0.23	0.22	0.22
query6	1.21	1.04	1.11
query7	0.04	0.01	0.01
query8	0.06	0.03	0.03
query9	0.38	0.30	0.29
query10	0.55	0.59	0.56
query11	0.19	0.13	0.13
query12	0.17	0.15	0.14
query13	0.48	0.47	0.49
query14	1.00	1.02	1.01
query15	0.63	0.60	0.60
query16	0.32	0.31	0.33
query17	1.12	1.15	1.12
query18	0.23	0.21	0.21
query19	2.07	1.97	1.88
query20	0.02	0.01	0.01
query21	15.41	0.21	0.14
query22	4.94	0.06	0.05
query23	16.15	0.32	0.11
query24	3.16	0.43	0.35
query25	0.12	0.06	0.05
query26	0.75	0.20	0.14
query27	0.05	0.04	0.05
query28	3.53	0.95	0.52
query29	12.49	4.20	3.30
query30	0.28	0.15	0.15
query31	2.77	0.57	0.31
query32	3.22	0.59	0.50
query33	3.12	3.20	3.22
query34	15.60	4.25	3.50
query35	3.51	3.52	3.53
query36	0.56	0.44	0.42
query37	0.09	0.07	0.06
query38	0.05	0.04	0.03
query39	0.03	0.02	0.02
query40	0.18	0.16	0.15
query41	0.08	0.03	0.03
query42	0.04	0.02	0.02
query43	0.05	0.03	0.03
Total cold run time: 96.84 s
Total hot run time: 24.96 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 71.28% (67/94) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 75.38% (31109/41272)
Line Coverage 59.92% (346656/578569)
Region Coverage 56.55% (290792/514197)
Branch Coverage 58.03% (130211/224383)

Issue Number: None

Related PR: apache#66048

Problem Summary: Rowset write failures could be followed by retries that allocated additional segment IDs, while several early-return paths skipped data or index writer cleanup and could replace the original failure with a later close error. Latch the first write failure as terminal, make index close startup composable, and perform best-effort cleanup for normal, segcompaction, and vertical rowset writers while preserving the owner error.

Failed rowset writes now terminate the writer and close all rowset output writers while preserving the original error.

- Test: Unit Test
    - BE ASAN unit tests for segment/index collections, SegmentCreator terminal failures, segcompaction cleanup, and vertical final-flush cleanup
    - build-support/check-format.sh
- Behavior changed: Yes. A SegmentCreator rejects subsequent writes after its first write failure and returns that original error.
- Does this need documentation: No
@airborne12
airborne12 requested a review from luwei16 as a code owner July 26, 2026 04:01
@airborne12

Copy link
Copy Markdown
Member Author

run buildall

### What problem does this PR solve?

Issue Number: None

Related PR: apache#66048

Problem Summary: The rowset writer fix introduced a dedicated header solely to preserve the first close error and a local FinalizedSegment type that only carried index-cache preload metadata. Follow the existing Doris explicit first-error pattern instead of expanding the common Status API or keeping a one-function header, reuse SegmentIndexFileCachePreloadTask, and gate index-cache preload on completion of all segment and index closes.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - 8 targeted BE ASAN unit tests for collection cleanup, terminal SegmentCreator failures, index-close preload gating, segcompaction cleanup, and vertical final-flush cleanup
    - build-support/check-format.sh
    - build-support/run-clang-tidy.sh --build-dir be/ut_build_ASAN (blocked by pre-existing types.h NOLINT and toolchain stddef.h errors)
- Behavior changed: Yes. Index-cache preload is skipped when index finish-close fails; first-error propagation and cleanup behavior are preserved.
- Does this need documentation: No
@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17706	4059	4065	4059
q2	2033	321	204	204
q3	10260	1438	865	865
q4	4680	469	343	343
q5	7547	864	606	606
q6	176	181	137	137
q7	742	840	620	620
q8	9374	1567	1565	1565
q9	5565	4356	4311	4311
q10	6771	1724	1469	1469
q11	511	366	319	319
q12	725	581	450	450
q13	18063	3356	2805	2805
q14	265	262	240	240
q15	q16	797	782	713	713
q17	1030	954	1038	954
q18	7072	5851	5525	5525
q19	1323	1421	1094	1094
q20	816	679	583	583
q21	6030	2647	2466	2466
q22	435	360	294	294
Total cold run time: 101921 ms
Total hot run time: 29622 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4379	4301	4281	4281
q2	294	317	210	210
q3	4584	4933	4460	4460
q4	2071	2140	1368	1368
q5	4370	4283	4331	4283
q6	226	179	129	129
q7	1729	1979	1867	1867
q8	2545	2158	2166	2158
q9	8116	8140	7739	7739
q10	4671	4731	4216	4216
q11	627	427	376	376
q12	762	766	535	535
q13	3266	3528	2979	2979
q14	311	311	276	276
q15	q16	708	727	635	635
q17	1376	1331	1472	1331
q18	8069	7402	7241	7241
q19	1107	1050	1094	1050
q20	2205	2198	1926	1926
q21	5235	4500	4351	4351
q22	509	471	410	410
Total cold run time: 57160 ms
Total hot run time: 51821 ms

@hello-stephen

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

query5	4358	639	489	489
query6	463	225	198	198
query7	4905	620	348	348
query8	334	187	174	174
query9	8822	4023	4023	4023
query10	489	338	296	296
query11	5921	2360	2150	2150
query12	164	105	102	102
query13	1261	625	446	446
query14	6259	5200	4896	4896
query14_1	4231	4216	4195	4195
query15	218	203	179	179
query16	1063	492	461	461
query17	1147	744	584	584
query18	2722	492	362	362
query19	221	198	159	159
query20	113	110	106	106
query21	233	161	134	134
query22	13542	13562	13444	13444
query23	17455	16533	16168	16168
query23_1	16343	16270	16241	16241
query24	7512	1773	1267	1267
query24_1	1304	1292	1280	1280
query25	575	487	388	388
query26	1339	383	215	215
query27	2468	605	373	373
query28	4374	1976	2002	1976
query29	1077	632	513	513
query30	337	277	226	226
query31	1121	1097	985	985
query32	108	63	62	62
query33	548	342	256	256
query34	1172	1166	645	645
query35	770	780	681	681
query36	1166	1159	1036	1036
query37	155	111	98	98
query38	1880	1718	1659	1659
query39	872	887	839	839
query39_1	828	849	856	849
query40	297	162	150	150
query41	66	63	62	62
query42	93	86	91	86
query43	323	319	270	270
query44	1467	761	754	754
query45	193	187	172	172
query46	1062	1204	727	727
query47	2124	2118	2001	2001
query48	410	415	295	295
query49	586	424	303	303
query50	1065	415	333	333
query51	10746	10869	10858	10858
query52	84	88	74	74
query53	255	274	196	196
query54	280	227	212	212
query55	73	71	63	63
query56	305	292	305	292
query57	1323	1299	1207	1207
query58	285	264	257	257
query59	1533	1615	1425	1425
query60	315	267	250	250
query61	150	145	143	143
query62	536	497	438	438
query63	246	195	208	195
query64	2811	1026	834	834
query65	4705	4586	4637	4586
query66	1770	528	378	378
query67	29224	29221	29034	29034
query68	3207	1536	1049	1049
query69	406	294	267	267
query70	1072	959	936	936
query71	347	334	317	317
query72	3044	2726	2345	2345
query73	821	865	416	416
query74	5058	4924	4695	4695
query75	2573	2499	2139	2139
query76	2330	1247	809	809
query77	357	375	267	267
query78	11771	11987	11278	11278
query79	1436	1230	737	737
query80	1297	585	458	458
query81	559	334	284	284
query82	607	155	121	121
query83	384	323	303	303
query84	284	160	129	129
query85	988	612	548	548
query86	418	292	266	266
query87	1816	1808	1754	1754
query88	3745	2797	2785	2785
query89	432	386	328	328
query90	1991	190	199	190
query91	192	191	160	160
query92	62	59	55	55
query93	1713	1645	973	973
query94	710	366	291	291
query95	776	599	481	481
query96	1069	850	336	336
query97	2645	2649	2479	2479
query98	215	204	206	204
query99	1086	1104	967	967
Total cold run time: 263928 ms
Total hot run time: 177366 ms

@hello-stephen

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

query1	0.01	0.00	0.01
query2	0.10	0.08	0.05
query3	0.25	0.13	0.13
query4	1.61	0.14	0.14
query5	0.24	0.22	0.22
query6	1.27	1.08	1.06
query7	0.03	0.01	0.01
query8	0.06	0.04	0.04
query9	0.38	0.32	0.31
query10	0.57	0.59	0.59
query11	0.19	0.14	0.13
query12	0.18	0.15	0.14
query13	0.46	0.47	0.47
query14	1.02	1.03	1.01
query15	0.62	0.59	0.60
query16	0.32	0.33	0.31
query17	1.10	1.08	1.13
query18	0.23	0.21	0.22
query19	2.04	1.98	1.97
query20	0.02	0.01	0.01
query21	15.45	0.23	0.14
query22	4.77	0.06	0.05
query23	16.12	0.30	0.13
query24	2.92	0.42	0.30
query25	0.10	0.05	0.04
query26	0.73	0.21	0.15
query27	0.04	0.04	0.03
query28	3.53	0.92	0.54
query29	12.47	4.14	3.28
query30	0.27	0.15	0.16
query31	2.79	0.59	0.31
query32	3.22	0.59	0.49
query33	3.14	3.19	3.26
query34	15.50	4.17	3.52
query35	3.57	3.50	3.52
query36	0.56	0.43	0.42
query37	0.09	0.06	0.06
query38	0.06	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.16	0.16
query41	0.09	0.03	0.04
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 96.42 s
Total hot run time: 25.09 s

### What problem does this PR solve?

Issue Number: None

Related PR: apache#66048

Problem Summary: Segment index cache preload task ownership was duplicated across rowset writer paths and leaked cache-specific task construction into vertical final flushing. Centralize buffering and gating in the existing loader module, preserve segment-internal index preload when no inverted index exists, and skip preload after any write or close failure while still closing all writers and returning the first error.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - 13 targeted ASAN BE unit tests
- Behavior changed: Yes. Segment index cache preload runs only after all writes and file closes succeed.
- Does this need documentation: No
@airborne12
airborne12 requested a review from liaoxin01 as a code owner July 26, 2026 06:02
@airborne12

Copy link
Copy Markdown
Member Author

run buildall

@airborne12

Copy link
Copy Markdown
Member Author

/review

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17801	4053	4032	4032
q2	2006	322	203	203
q3	10335	1489	817	817
q4	4686	477	343	343
q5	7497	873	580	580
q6	176	168	133	133
q7	761	812	606	606
q8	9384	1590	1632	1590
q9	5557	4330	4327	4327
q10	6759	1750	1491	1491
q11	505	353	322	322
q12	714	572	470	470
q13	18094	3365	2683	2683
q14	263	263	243	243
q15	q16	781	772	707	707
q17	972	998	976	976
q18	7012	5825	5802	5802
q19	1373	1225	1087	1087
q20	784	665	549	549
q21	5837	2634	2488	2488
q22	431	355	293	293
Total cold run time: 101728 ms
Total hot run time: 29742 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4399	4312	4329	4312
q2	302	318	213	213
q3	4623	4990	4396	4396
q4	2084	2171	1387	1387
q5	4388	4288	4276	4276
q6	226	177	127	127
q7	1763	1968	1894	1894
q8	2560	2255	2227	2227
q9	8013	8077	7813	7813
q10	4704	4653	4231	4231
q11	561	412	376	376
q12	795	778	546	546
q13	3293	3551	2956	2956
q14	301	297	292	292
q15	q16	718	743	644	644
q17	1339	1358	1338	1338
q18	7926	7521	7270	7270
q19	1168	1157	1078	1078
q20	2222	2204	1934	1934
q21	5236	4527	4410	4410
q22	533	444	404	404
Total cold run time: 57154 ms
Total hot run time: 52124 ms

@hello-stephen

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

query5	4336	634	464	464
query6	471	240	227	227
query7	4857	594	345	345
query8	343	197	175	175
query9	8817	4134	4076	4076
query10	500	359	325	325
query11	5939	2339	2127	2127
query12	154	103	102	102
query13	1269	625	446	446
query14	6255	5215	4912	4912
query14_1	4262	4282	4234	4234
query15	225	209	179	179
query16	1002	469	464	464
query17	922	730	578	578
query18	2462	474	350	350
query19	207	191	155	155
query20	111	109	108	108
query21	231	158	136	136
query22	13588	13589	13422	13422
query23	17434	16528	16137	16137
query23_1	16283	16230	16315	16230
query24	7524	1754	1272	1272
query24_1	1282	1296	1261	1261
query25	572	462	395	395
query26	1349	362	211	211
query27	2613	584	381	381
query28	4479	2044	1992	1992
query29	1109	623	508	508
query30	343	272	227	227
query31	1131	1091	984	984
query32	115	63	63	63
query33	533	325	263	263
query34	1198	1107	645	645
query35	759	786	668	668
query36	1213	1195	1102	1102
query37	155	152	91	91
query38	1881	1655	1644	1644
query39	862	867	833	833
query39_1	831	828	838	828
query40	253	159	138	138
query41	65	63	63	63
query42	94	97	90	90
query43	324	330	279	279
query44	1384	755	760	755
query45	191	187	169	169
query46	1057	1188	729	729
query47	2124	2100	2024	2024
query48	419	421	288	288
query49	585	408	311	311
query50	1081	443	340	340
query51	11050	10897	10964	10897
query52	85	84	75	75
query53	256	297	205	205
query54	284	225	209	209
query55	75	74	64	64
query56	309	279	302	279
query57	1306	1271	1186	1186
query58	288	266	261	261
query59	1582	1610	1426	1426
query60	301	258	257	257
query61	154	150	150	150
query62	546	495	426	426
query63	241	199	196	196
query64	2813	1063	835	835
query65	4713	4618	4603	4603
query66	1873	498	372	372
query67	29250	29203	29070	29070
query68	3217	1461	1016	1016
query69	411	298	251	251
query70	1079	945	942	942
query71	352	322	316	316
query72	3111	2261	2316	2261
query73	818	739	436	436
query74	5050	4915	4711	4711
query75	2506	2501	2148	2148
query76	2363	1160	766	766
query77	345	376	283	283
query78	11866	11921	11301	11301
query79	1352	1135	775	775
query80	1297	577	466	466
query81	497	327	302	302
query82	571	159	123	123
query83	392	325	290	290
query84	331	163	130	130
query85	984	622	517	517
query86	427	309	294	294
query87	1828	1832	1757	1757
query88	3648	2815	2764	2764
query89	425	374	335	335
query90	1881	203	197	197
query91	207	190	163	163
query92	65	60	55	55
query93	1581	1538	1032	1032
query94	712	347	323	323
query95	783	624	456	456
query96	1030	769	357	357
query97	2629	2656	2515	2515
query98	212	208	202	202
query99	1091	1109	979	979
Total cold run time: 263667 ms
Total hot run time: 177821 ms

@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.

Automated review result: request changes.

I found one blocking lifecycle gap: a delete-bitmap calculation failure bypasses terminal cleanup of the normal rowset data/index writers in both the changed local path and the parallel cloud path. See the inline comment for the concrete trigger and fix boundary.

Critical checkpoints:

  • Goal and proof: The PR substantially implements terminal SegmentCreator failures, first-status preservation, all-writer close attempts, and post-close cache preload. It does not fully accomplish the cleanup goal because the new bitmap-error exit skips the normal writer ownership tree. The added tests do not cover this local/cloud failure path.
  • Scope and clarity: The patch is focused on rowset writer failure handling and cache-preload lifecycle; no unrelated production changes were found.
  • Concurrency: AtomicStatus publication and the queued/running segcompaction cancellation handoff were traced through their condition-variable and ownership interleavings. No additional race or deadlock was substantiated.
  • Lifecycle, error handling, and data writes: Normal, vertical, and segcompaction close ordering otherwise preserves the owner/first error and attempts later closes. The accepted inline issue is the remaining failure exit that can leave buffered or asynchronously closing normal writers without the required cleanup/finish step.
  • Configuration and special conditions: No new configuration was added. Existing mutable index-only cache behavior and the idempotent begin_close condition were reviewed; no separate configuration defect was confirmed.
  • Compatibility and parallel paths: No storage-format, symbol, protocol, or rolling-upgrade change was introduced, and the more-specific Status propagation is intentional. CloudRowsetWriter is the missing functional parallel path covered by the inline finding.
  • Tests and results: The targeted BE tests cover terminal write failures, first-error cleanup, vertical failure cleanup, fatal segcompaction status, and preload gating, but not the accepted bitmap-error cleanup path. Per the review-run contract, no local build or test was attempted. At submission time, compile, formatter, CheckStyle, and several checks pass; coverage is failing, while BE UT and several regression jobs remain pending.
  • Observability and performance: Failure logs retain concrete Status values and identifiers, and no material hot-path regression was found. The unclosed remote-writer path can waste buffered/multipart resources, which is part of the blocking finding.
  • Transactions, persistence, and FE/BE variables: No EditLog, persistent metadata schema, transaction commit protocol, or FE-BE variable propagation change is involved. Successful rowset visibility semantics are unchanged; the issue is cleanup after an already-failed write.
  • User focus: No additional user-provided focus was specified.

The full 14-file authoritative diff and relevant upstream/downstream paths were reviewed. Two ledger rounds converged with all three round-2 agents reporting NO_NEW_VALUABLE_FINDINGS for head bb418e0.

RETURN_IF_ERROR(_calc_delete_bitmap_token->wait());
auto delete_bitmap_status = _calc_delete_bitmap_token->wait();
if (!delete_bitmap_status.ok()) {
WARN_IF_ERROR(_synchronize_segcompaction(),

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.

[P1] Finish normal rowset writers on bitmap failure

This branch returns after cleaning only SegcompactionWorker, so the normal SegmentCreator ownership tree is skipped. A prior segment's delete-bitmap task can fail after a later segment is buffered; moreover, flushed inverted-index writers have only run begin_close() and still need InvertedIndexFileCollection::finish_close(). The same early return remains in CloudRowsetWriter::build(), where S3/packed-writer destruction is not equivalent to a successful explicit close and can leave multipart/buffered output abandoned. Please preserve delete_bitmap_status, mark/discard any buffered creator writer, and run a cleanup-only close for all normal data/index writers in both local and cloud build paths before returning. This should not reuse the success path unchanged because that may flush/preload or apply segcompaction/delete-bitmap conversion after the owner failure.

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.09	0.05	0.05
query3	0.25	0.14	0.13
query4	1.60	0.14	0.14
query5	0.23	0.22	0.22
query6	1.26	1.12	1.07
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.36	0.30	0.31
query10	0.59	0.55	0.56
query11	0.19	0.13	0.14
query12	0.18	0.14	0.14
query13	0.49	0.47	0.48
query14	1.02	1.00	0.98
query15	0.62	0.59	0.59
query16	0.31	0.31	0.32
query17	1.10	1.11	1.10
query18	0.23	0.21	0.22
query19	1.99	2.00	1.95
query20	0.02	0.01	0.01
query21	15.43	0.21	0.14
query22	4.76	0.05	0.05
query23	16.12	0.30	0.12
query24	3.00	0.41	0.34
query25	0.11	0.06	0.04
query26	0.72	0.21	0.14
query27	0.04	0.04	0.03
query28	3.59	0.92	0.54
query29	12.47	4.16	3.29
query30	0.27	0.16	0.16
query31	2.77	0.58	0.31
query32	3.23	0.59	0.47
query33	3.25	3.16	3.19
query34	15.48	4.26	3.48
query35	3.50	3.49	3.52
query36	0.58	0.43	0.41
query37	0.09	0.07	0.07
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.16	0.15
query41	0.08	0.03	0.04
query42	0.03	0.03	0.03
query43	0.05	0.04	0.04
Total cold run time: 96.48 s
Total hot run time: 24.97 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 82.74% (187/226) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.87% (30523/41319)
Line Coverage 57.92% (335736/579688)
Region Coverage 54.14% (278931/515232)
Branch Coverage 55.09% (123988/225069)

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