Skip to content

[refactor](storage) move flexible partial-update fill into the block transform - #66774

Open
csun5285 wants to merge 2 commits into
apache:masterfrom
csun5285:refactor/flexible-pu-fill-stage
Open

[refactor](storage) move flexible partial-update fill into the block transform#66774
csun5285 wants to merge 2 commits into
apache:masterfrom
csun5285:refactor/flexible-pu-fill-stage

Conversation

@csun5285

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

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

… decouple BlockAggregator; segment writers become pure storage-format sinks

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@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?

@csun5285

Copy link
Copy Markdown
Contributor 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.

Request changes

I found two blocking issues:

  • A flexible sequence block can shrink to zero after its segment ID is allocated. Because neither flusher publishes that ID, a later segment leaves a permanent numbering gap; default metadata construction can then declare zero segments and readers omit valid later data.
  • The existing horizontal-writer regression still requires the exact NotSupported error removed here, so the intended newly successful path fails that suite deterministically.

Checkpoint conclusions:

  • Goal, scope, and tests: The storage-only refactor consistently moves flexible fill before writer selection and adds broad BE semantic/persistence coverage. The tests miss the zero-then-nonempty segment sequence, and the existing docker regression was not updated. I did not run local builds or tests because the review-runner instructions prohibit them.
  • Correctness, persistence, and errors: Sequence/default/null/delete/skip-bitmap behavior and ordinary Status propagation otherwise match the legacy vertical path. The unresolved zero-row success path breaks the rowset's physical segment/collector/metadata contract and can hide committed rows.
  • Concurrency and lifecycle: Per-flush transform state, atomic counters, delete-bitmap synchronization, historical-row pins, and RowStore/Variant COW generator lifetimes are sound outside the reported segment-publication boundary.
  • Configuration, compatibility, and parallel paths: No new configuration, FE-BE variable, wire protocol, or storage format is introduced. Both writer modes and the V2, group/binlog, cloud, compaction, schema-change, transient, and segcompaction paths were traced; the existing enable_vertical_segment_writer=false mode is where the PR newly exposes both reported problems.
  • Observability and performance: Existing probe counters, logging, and error reporting are otherwise preserved, and I found no separate material performance regression.

No additional user review focus was supplied.

Comment thread be/src/storage/transform/block_transform.cpp
Comment thread be/src/storage/segment/segment_writer.cpp
The horizontal SegmentWriter accepts flexible partial update now that the
transform chain fills blocks before any writer runs, so make the coverage
follow:

- test_f_segment_writer.groovy pinned the deleted NotSupported rejection.
  It now requires the load to succeed and checks the updated rows and skip
  bitmaps; the expected values match test_flexible_partial_update.groovy,
  which runs the same load on the vertical path. It also reads the rows
  once more right before the load, so an unexpected change shows up there
  instead of in the post-update check.
- The golden suite replays flexible partial update through both writers
  (kFlexiblePartialWriterModes). The vertical baselines stay the ones
  recorded from the legacy in-writer fill; the horizontal baselines are
  new, since the legacy horizontal writer rejected flexible and no legacy
  baseline can exist for it.
- enable_vertical_segment_writer joins the fuzzy config set so pipeline
  runs exercise both writers. The only two suites that enable a
  VerticalSegmentWriter debug point either switch the config themselves or
  use a point that now lives in the fill stage, so neither depends on the
  default.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@csun5285

Copy link
Copy Markdown
Contributor 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.

Automated follow-up review completed. Round 1 converged with no new distinct inline findings.

Outcome: no new valuable findings beyond the existing review context. The horizontal regression concern from discussion_r3782501198 is addressed at this head. The empty-post-transform segment-numbering condition from discussion_r3782501187 is still reproducible in the code, although that thread is now marked resolved; I did not duplicate it.

Checkpoint conclusions:

  • Goal and proof: the change moves flexible partial-update fill and aggregation into the shared block-transform chain so both segment writers consume the same full-width block. The changed unit, format, and regression coverage exercises horizontal success, fill semantics, row accounting, skip bitmaps, primary-key keys, row-store data, sequence behavior, and two-segment persistence.
  • Scope: the production changes are confined to the storage transform/writer path and the tests and golden data needed for the newly supported horizontal behavior. The PR description remains an unfilled template, so the intended goal was validated from the title, implementation, and tests.
  • Data correctness and transactions: the MoW snapshot/max-version boundary, temporary delete marks, sequence-loser behavior, insert-after-delete handling, default/null fill, and final row positions match the former vertical path. The previously reported empty-first-segment gap remains the only substantiated correctness concern.
  • Concurrency and lifecycle: transform state is local per flush, shared counters remain atomic, and existing publication locks are unchanged. Historical rowsets remain pinned through fill, and the RowStore COW generator and probe/fetcher/aggregator reference lifetimes are sound.
  • Configuration, compatibility, and parallel paths: no new configuration, protocol, or storage-format contract is introduced. The existing mutable writer-selection flag is exercised, and partial fill is fenced to the context-rich flush_single_block path; streaming, V2, row-binlog, compaction, segcompaction, schema-change, and transient paths were checked for accidental reachability.
  • Errors, observability, and performance: transform and writer statuses cross the existing error boundary without being discarded. Existing counters and logging remain appropriate, and no separate concrete performance regression was found.
  • Test coverage: both writer modes, aggregation shrink, sequence/self marks, row-store, logical persistence, input-row accounting, and two segments have direct coverage. The absent all-empty-first-then-nonempty case is the same boundary already described by discussion_r3782501187.
  • User focus: no additional focus was supplied, so the whole PR was reviewed.

Review completion: converged after one complete normal and risk-focused round; all candidate points were adjudicated, with zero new inline comments.

@csun5285

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17550	3069	3060	3060
q2	1874	225	152	152
q3	10484	866	513	513
q4	4664	241	196	196
q5	7690	595	385	385
q6	138	117	93	93
q7	524	508	388	388
q8	9255	898	975	898
q9	3466	2365	2364	2364
q10	6526	873	715	715
q11	441	261	237	237
q12	691	389	323	323
q13	17889	1862	1561	1561
q14	161	151	137	137
q15	q16	442	405	365	365
q17	811	806	778	778
q18	3109	2275	2227	2227
q19	1269	874	800	800
q20	646	545	446	446
q21	5654	1875	1909	1875
q22	342	279	233	233
Total cold run time: 93626 ms
Total hot run time: 17746 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3410	3376	3334	3334
q2	213	213	155	155
q3	2203	2352	2186	2186
q4	1179	1164	882	882
q5	2194	2127	2088	2088
q6	170	120	86	86
q7	1077	899	872	872
q8	1603	1424	1398	1398
q9	3056	3050	3015	3015
q10	1873	1783	1640	1640
q11	350	268	252	252
q12	460	439	342	342
q13	1828	1833	1566	1566
q14	176	174	160	160
q15	q16	401	397	371	371
q17	1055	1041	1024	1024
q18	4870	4392	4749	4392
q19	888	833	854	833
q20	958	939	800	800
q21	3882	3172	3304	3172
q22	402	456	340	340
Total cold run time: 32248 ms
Total hot run time: 28908 ms

@hello-stephen

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

query5	4247	409	329	329
query6	412	160	148	148
query7	4897	435	260	260
query8	290	123	108	108
query9	8688	2918	2909	2909
query10	434	265	228	228
query11	5392	1031	922	922
query12	115	73	70	70
query13	1197	429	324	324
query14	5955	2010	1865	1865
query14_1	1774	1744	1758	1744
query15	180	124	112	112
query16	927	387	363	363
query17	819	462	361	361
query18	2339	358	236	236
query19	173	145	117	117
query20	70	68	71	68
query21	213	119	101	101
query22	5419	5304	5340	5304
query23	7387	6757	6345	6345
query23_1	6529	6595	6660	6595
query24	7297	1117	749	749
query24_1	764	773	801	773
query25	409	285	229	229
query26	1245	255	158	158
query27	2736	457	289	289
query28	4605	1503	1527	1503
query29	934	432	338	338
query30	275	174	151	151
query31	969	669	615	615
query32	96	49	52	49
query33	458	210	162	162
query34	990	813	464	464
query35	413	399	337	337
query36	560	545	512	512
query37	133	95	76	76
query38	993	827	821	821
query39	543	503	530	503
query39_1	480	537	543	537
query40	228	122	107	107
query41	52	50	51	50
query42	74	74	73	73
query43	254	258	213	213
query44	1059	560	568	560
query45	112	106	99	99
query46	803	836	552	552
query47	991	978	971	971
query48	317	314	233	233
query49	537	233	191	191
query50	792	328	255	255
query51	8024	8077	8076	8076
query52	68	69	61	61
query53	204	213	164	164
query54	230	188	177	177
query55	74	59	57	57
query56	235	239	211	211
query57	650	624	610	610
query58	237	199	213	199
query59	1137	1108	993	993
query60	274	230	204	204
query61	137	152	139	139
query62	363	212	175	175
query63	191	159	158	158
query64	2677	655	525	525
query65	1576	1555	1566	1555
query66	1793	309	235	235
query67	9739	9504	9674	9504
query68	2762	1149	749	749
query69	338	230	203	203
query70	644	613	594	594
query71	296	262	238	238
query72	2300	1760	1548	1548
query73	658	618	346	346
query74	1610	1225	1141	1141
query75	1206	1143	979	979
query76	2300	735	531	531
query77	250	250	203	203
query78	5124	4714	4472	4472
query79	1183	922	603	603
query80	1176	382	339	339
query81	458	193	168	168
query82	590	142	112	112
query83	351	259	238	238
query84	303	124	105	105
query85	844	432	389	389
query86	357	173	176	173
query87	1005	990	885	885
query88	2808	2137	2147	2137
query89	311	228	205	205
query90	1820	142	138	138
query91	151	141	119	119
query92	49	50	45	45
query93	1258	1083	718	718
query94	606	251	224	224
query95	653	345	330	330
query96	769	595	294	294
query97	1072	1071	1031	1031
query98	142	131	134	131
query99	414	338	306	306
Total cold run time: 177426 ms
Total hot run time: 84901 ms

@hello-stephen

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

query1	0.00	0.01	0.00
query2	0.07	0.03	0.03
query3	0.25	0.12	0.10
query4	1.60	0.10	0.10
query5	0.17	0.16	0.15
query6	1.27	0.70	0.67
query7	0.03	0.00	0.01
query8	0.05	0.03	0.03
query9	0.29	0.20	0.21
query10	0.35	0.34	0.33
query11	0.15	0.11	0.12
query12	0.15	0.12	0.11
query13	0.29	0.29	0.32
query14	0.47	0.46	0.47
query15	0.37	0.34	0.36
query16	0.23	0.21	0.22
query17	0.70	0.68	0.73
query18	0.18	0.16	0.16
query19	1.19	1.19	1.20
query20	0.01	0.01	0.01
query21	15.45	0.16	0.11
query22	5.09	0.04	0.04
query23	16.18	0.27	0.10
query24	2.98	0.34	0.26
query25	0.13	0.03	0.04
query26	0.77	0.16	0.13
query27	0.03	0.03	0.04
query28	3.66	0.52	0.28
query29	12.46	3.16	2.60
query30	0.25	0.12	0.12
query31	2.76	0.38	0.18
query32	3.51	0.31	0.23
query33	1.47	1.40	1.45
query34	15.36	2.21	1.79
query35	1.80	1.74	1.72
query36	0.46	0.29	0.29
query37	0.06	0.04	0.04
query38	0.05	0.03	0.03
query39	0.04	0.02	0.02
query40	0.11	0.08	0.07
query41	0.08	0.02	0.02
query42	0.03	0.02	0.02
query43	0.03	0.03	0.03
Total cold run time: 90.58 s
Total hot run time: 14.71 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 93.51% (173/185) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 60.44% (26582/43981)
Line Coverage 44.84% (271013/604435)
Region Coverage 40.60% (216208/532536)
Branch Coverage 42.04% (99501/236709)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 96.76% (179/185) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.76% (32032/42849)
Line Coverage 59.18% (355069/599953)
Region Coverage 55.41% (295551/533404)
Branch Coverage 56.32% (133267/236605)

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