Skip to content

[fix](binlog) Fix row binlog routing for auto partitions - #66665

Merged
hello-stephen merged 1 commit into
apache:masterfrom
HappenLee:fix-row-binlog-auto-partition
Aug 13, 2026
Merged

hello-stephen merged 1 commit into
apache:masterfrom
HappenLee:fix-row-binlog-auto-partition

Conversation

@HappenLee

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Creating an automatic partition returned the row binlog index as a regular partition index even though the sink schema carries row binlog separately. BE therefore rejected the partition because its index count did not match the schema. The response also omitted the base tablet mapping required to route row binlog writes. Exclude row binlog indexes from partition metadata, return their tablet locations with base tablet IDs, and reuse colocated replica placement in local mode.

Release note

Fix imports into auto-partitioned tables with row binlog enabled.

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

    Unit Test: FrontendServiceImplTest (20 tests passed).

    Regression test: row_binlog_p0/test_row_binlog_auto_partition.

  • Behavior changed:

    • No.
    • Yes. Auto partition imports now route row binlog tablets correctly.
  • 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

Issue Number: None

Related PR: None

Problem Summary: Creating an automatic partition returned the row binlog index as a regular partition index even though the sink schema carries row binlog separately. BE therefore rejected the partition because its index count did not match the schema. The response also omitted the base tablet mapping required to route row binlog writes. Exclude row binlog indexes from partition metadata, return their tablet locations with base tablet IDs, and reuse colocated replica placement in local mode.

Fix imports into auto-partitioned tables with row binlog enabled.

- Test: Regression test / Unit Test
    - Unit Test: FrontendServiceImplTest (20 tests)
    - Regression test: row_binlog_p0/test_row_binlog_auto_partition
- Behavior changed: Yes. Auto partition imports now route row binlog tablets correctly.
- 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?

@morrySnow morrySnow changed the title [fix](fe) Fix row binlog routing for auto partitions [fix](binlog) Fix row binlog routing for auto partitions Aug 11, 2026
@HappenLee

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 review complete: no blocking issues found and no inline comments are proposed.

The change fixes the FE/BE contract for row-binlog auto partitions: TOlapTablePartition.indexes now contains only the ordinary indexes represented by the sink schema, while companion row-binlog tablets are returned as locations carrying the existing base_tablet_id mapping. The same construction is used by auto-create and insert-overwrite replacement, and local mode reuses the established same-disk intersection logic.

Critical checkpoint conclusions:

  • Goal and proof: The implementation addresses both reported failure modes (index-count mismatch and missing companion routing). The FE unit test checks ordinary-index cardinality and every returned row-binlog base-tablet ID; the regression test performs a real two-partition insert and verifies both table rows and row-binlog rows with deterministic ordering.
  • Scope and clarity: The production change is focused on one shared snapshot representation plus reuse of the existing colocation helper. No unrelated behavior was changed.
  • Concurrency and lifecycle: Partition/index/tablet relationships are captured while the table read lock is held. The existing concurrent auto-partition cache retains the complete TTabletLocation objects, including base_tablet_id, and create/replace callbacks install locations before incremental channel opening. No new threads, lock ordering, static initialization, or resource-lifetime mechanism is introduced.
  • Configuration and compatibility: No configuration, storage format, function symbol, or persistence format changes are introduced. base_tablet_id is an existing optional Thrift field. Ordinary schema indexes and row-binlog schemas remain separately transmitted, matching all BE partition constructors; row-binlog sinks remain explicitly gated away from the V2 writer that does not consume this mapping.
  • Parallel and conditional paths: Reviewed create versus replace, cache hit versus miss, local versus cloud routing, adaptive-random-bucket handling, rollup/shadow index ordering, and replacement-result conversion. Extra row-binlog locations do not enter ordinary index or adaptive bucket assignment; cloud mode uses the intended base-tablet fallback independent of node placement.
  • Transactions and data correctness: On local nodes without a colocated companion, BE omits the row-binlog writer, but the transaction's loaded-index set includes the row-binlog index. Normal commit, 2PC precommit, and publish enforce its configured load-required replica count before visibility, so a partial base-only result cannot become visible. There are no delete-bitmap or visible-version changes.
  • Error handling and observability: The new invariant failure for a missing base tablet is explicit. Existing commit/quorum errors and tablet identifiers provide the relevant failure evidence; no additional metric or logging path is required for this focused routing fix.
  • Performance and memory: Work remains linear in the number of tablets/replicas. The extra companion snapshot/location objects are required for routing, with no new heavy work under locks or untracked BE allocation.
  • Test standards/results: The new regression drops before use, orders both result sets, and includes the generated output. The PR reports the FE test class and regression case as passed; visible CI style/license/title checks are also passing. Per the review-runner instruction, this review did not rerun builds or tests.
  • Additional user focus: No extra review focus was provided. The full PR was reviewed.

Review convergence: both complete-review agents and the separate risk-focused agent returned NO_NEW_VALUABLE_FINDINGS; the one degraded-colocation suspicion was dismissed with end-to-end commit/precommit/publish evidence. The final changed-file and unresolved-candidate sweep found no remaining issue.

@HappenLee

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17592	3943	3951	3943
q2	2048	329	204	204
q3	10282	1391	783	783
q4	4680	464	336	336
q5	7544	860	550	550
q6	172	168	135	135
q7	754	801	598	598
q8	9333	1623	1632	1623
q9	5302	4079	4051	4051
q10	6772	1642	1372	1372
q11	506	356	334	334
q12	711	568	453	453
q13	18115	3214	2763	2763
q14	262	255	243	243
q15	q16	729	725	658	658
q17	1037	1067	981	981
q18	6467	5607	5607	5607
q19	1151	1327	976	976
q20	790	678	578	578
q21	5058	2559	2402	2402
q22	424	341	301	301
Total cold run time: 99729 ms
Total hot run time: 28891 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4310	4221	4201	4201
q2	270	335	207	207
q3	4536	4919	4384	4384
q4	2174	2252	1415	1415
q5	4205	4085	4154	4085
q6	235	171	127	127
q7	1698	1587	1418	1418
q8	2185	2509	2187	2187
q9	7367	7467	7474	7467
q10	4407	4285	3858	3858
q11	546	401	397	397
q12	738	726	499	499
q13	3285	3512	2910	2910
q14	299	311	291	291
q15	q16	712	726	650	650
q17	1329	1293	1274	1274
q18	12300	11081	11721	11081
q19	1193	1162	1182	1162
q20	2225	2222	1922	1922
q21	5721	4865	4866	4865
q22	547	490	419	419
Total cold run time: 60282 ms
Total hot run time: 54819 ms

@hello-stephen

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

query5	4313	606	455	455
query6	472	224	206	206
query7	4829	554	330	330
query8	321	167	150	150
query9	8767	4001	4018	4001
query10	504	369	301	301
query11	5787	2222	2008	2008
query12	158	99	94	94
query13	1243	618	444	444
query14	6061	4254	3965	3965
query14_1	3810	3803	3759	3759
query15	196	192	177	177
query16	967	468	430	430
query17	891	658	533	533
query18	2416	465	323	323
query19	201	186	141	141
query20	100	100	103	100
query21	232	156	138	138
query22	13111	12988	12879	12879
query23	15818	15129	14644	14644
query23_1	15358	15080	15162	15080
query24	7805	1698	1225	1225
query24_1	1247	1222	1242	1222
query25	553	453	378	378
query26	1304	352	211	211
query27	2612	623	396	396
query28	4548	2002	1959	1959
query29	1042	587	472	472
query30	332	263	223	223
query31	1169	1103	1034	1034
query32	110	60	57	57
query33	514	292	226	226
query34	1184	1142	623	623
query35	730	747	641	641
query36	777	762	709	709
query37	148	105	89	89
query38	1810	1747	1686	1686
query39	833	822	791	791
query39_1	785	775	782	775
query40	244	161	135	135
query41	62	66	62	62
query42	90	90	89	89
query43	311	335	282	282
query44	1406	738	757	738
query45	184	174	164	164
query46	1037	1161	708	708
query47	1573	1580	1478	1478
query48	405	404	266	266
query49	580	399	303	303
query50	1059	433	329	329
query51	10579	10617	10442	10442
query52	90	87	79	79
query53	256	272	195	195
query54	298	224	225	224
query55	75	72	65	65
query56	311	285	286	285
query57	1037	1009	910	910
query58	284	271	285	271
query59	1538	1571	1374	1374
query60	308	284	257	257
query61	155	150	155	150
query62	397	328	265	265
query63	234	189	192	189
query64	2895	1046	865	865
query65	3848	3795	3816	3795
query66	1830	475	373	373
query67	20248	20051	20117	20051
query68	3079	1480	979	979
query69	408	297	261	261
query70	879	812	792	792
query71	372	367	319	319
query72	3050	2868	2150	2150
query73	853	748	397	397
query74	4605	4516	4336	4336
query75	2400	2363	2007	2007
query76	2329	1155	758	758
query77	344	379	291	291
query78	11201	11170	10535	10535
query79	1380	1101	722	722
query80	856	540	460	460
query81	488	324	284	284
query82	619	181	149	149
query83	399	329	295	295
query84	323	154	132	132
query85	985	613	534	534
query86	370	234	214	214
query87	2011	1964	1841	1841
query88	3694	2794	2775	2775
query89	385	311	278	278
query90	1852	191	201	191
query91	199	191	161	161
query92	62	58	60	58
query93	1515	1544	918	918
query94	608	343	318	318
query95	786	485	557	485
query96	1039	779	351	351
query97	2474	2499	2377	2377
query98	199	186	183	183
query99	753	758	633	633
Total cold run time: 244929 ms
Total hot run time: 158357 ms

@hello-stephen

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

query1	0.01	0.01	0.00
query2	0.09	0.04	0.04
query3	0.25	0.14	0.14
query4	1.61	0.14	0.14
query5	0.24	0.21	0.22
query6	1.17	0.80	0.85
query7	0.04	0.00	0.00
query8	0.05	0.04	0.03
query9	0.39	0.30	0.31
query10	0.54	0.54	0.55
query11	0.19	0.14	0.13
query12	0.18	0.13	0.15
query13	0.46	0.46	0.46
query14	1.00	0.98	0.99
query15	0.60	0.59	0.60
query16	0.31	0.31	0.30
query17	1.16	1.14	1.08
query18	0.20	0.20	0.19
query19	2.01	1.98	1.89
query20	0.01	0.01	0.02
query21	15.43	0.20	0.13
query22	4.98	0.05	0.05
query23	16.13	0.30	0.12
query24	2.99	0.42	0.32
query25	0.11	0.06	0.04
query26	0.72	0.20	0.16
query27	0.04	0.04	0.03
query28	3.50	0.72	0.34
query29	12.49	4.04	3.21
query30	0.27	0.16	0.15
query31	2.77	0.55	0.31
query32	3.22	0.60	0.50
query33	3.14	3.20	3.25
query34	15.71	3.94	3.28
query35	3.22	3.21	3.26
query36	0.57	0.42	0.42
query37	0.09	0.07	0.06
query38	0.05	0.04	0.03
query39	0.04	0.03	0.03
query40	0.18	0.17	0.15
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.03
Total cold run time: 96.32 s
Total hot run time: 23.79 s

@hello-stephen
hello-stephen merged commit 684ca81 into apache:master Aug 13, 2026
33 of 34 checks passed
wyxxxcat pushed a commit to wyxxxcat/doris that referenced this pull request Aug 17, 2026
Problem Summary: Creating an automatic partition returned the row binlog
index as a regular partition index even though the sink schema carries
row binlog separately. BE therefore rejected the partition because its
index count did not match the schema. The response also omitted the base
tablet mapping required to route row binlog writes. Exclude row binlog
indexes from partition metadata, return their tablet locations with base
tablet IDs, and reuse colocated replica placement in local mode.

### Release note

Fix imports into auto-partitioned tables with row binlog enabled.
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