Skip to content

[feature](binlog) Keep row binlog tablets colocated with base tablets - #66191

Merged
gavinchou merged 14 commits into
apache:masterfrom
AntiTopQuark:binlog_tablet_schedule
Sep 1, 2026
Merged

[feature](binlog) Keep row binlog tablets colocated with base tablets#66191
gavinchou merged 14 commits into
apache:masterfrom
AntiTopQuark:binlog_tablet_schedule

Conversation

@AntiTopQuark

@AntiTopQuark AntiTopQuark commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #65418

Related PR: #xxx

Problem Summary:

Applying the row binlog tablet locality patch series left duplicate hunks, rejected FE patch files, a missing scheduler exception declaration, and stale regression cases. Reconcile the final patch state so row binlog tablets use the existing colocate mismatch scheduling path to stay on the same backend and disk path as their paired base tablets without joining user colocate groups.

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

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

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run buildall

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17779	4016	3950	3950
q2	2011	322	194	194
q3	10318	1378	784	784
q4	4679	485	344	344
q5	7508	813	559	559
q6	180	165	133	133
q7	736	804	590	590
q8	9327	1547	1524	1524
q9	5646	4064	4043	4043
q10	6812	1633	1370	1370
q11	505	355	319	319
q12	704	563	446	446
q13	18094	3234	2748	2748
q14	267	260	237	237
q15	q16	721	731	657	657
q17	1136	1070	869	869
q18	6821	5779	5529	5529
q19	1312	1279	1049	1049
q20	817	694	564	564
q21	5573	2683	2349	2349
q22	423	351	301	301
Total cold run time: 101369 ms
Total hot run time: 28559 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4286	4148	4296	4148
q2	283	322	208	208
q3	4519	4929	4380	4380
q4	2180	2276	1444	1444
q5	4221	4088	4092	4088
q6	226	175	125	125
q7	1675	1614	1426	1426
q8	2707	2074	2080	2074
q9	7283	7255	7249	7249
q10	4294	4269	3848	3848
q11	572	400	371	371
q12	739	735	508	508
q13	3133	3661	2874	2874
q14	295	310	287	287
q15	q16	680	718	634	634
q17	1310	1303	1266	1266
q18	8028	7272	7292	7272
q19	1094	1050	1046	1046
q20	2212	2189	1932	1932
q21	5194	4571	4395	4395
q22	526	463	393	393
Total cold run time: 55457 ms
Total hot run time: 49968 ms

@hello-stephen

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

query5	4300	596	458	458
query6	472	223	197	197
query7	4883	622	332	332
query8	336	189	171	171
query9	8767	3985	3989	3985
query10	488	351	281	281
query11	5827	2173	2013	2013
query12	157	98	98	98
query13	1262	597	414	414
query14	6071	4652	4373	4373
query14_1	3817	3807	3805	3805
query15	208	202	181	181
query16	1025	483	396	396
query17	1120	690	584	584
query18	2467	445	328	328
query19	205	182	142	142
query20	106	101	101	101
query21	232	152	137	137
query22	13041	12959	12789	12789
query23	17243	16358	15983	15983
query23_1	16141	16096	16052	16052
query24	7541	1699	1223	1223
query24_1	1258	1223	1222	1222
query25	537	447	341	341
query26	1297	363	222	222
query27	2658	594	373	373
query28	4559	2077	2051	2051
query29	1070	612	470	470
query30	335	253	223	223
query31	1109	1055	960	960
query32	96	62	57	57
query33	521	307	249	249
query34	1182	1113	651	651
query35	731	754	633	633
query36	795	761	689	689
query37	149	103	90	90
query38	1837	1653	1619	1619
query39	826	822	798	798
query39_1	776	780	777	777
query40	245	166	147	147
query41	66	62	63	62
query42	90	89	91	89
query43	313	327	274	274
query44	1425	771	749	749
query45	192	177	165	165
query46	1040	1158	729	729
query47	1578	1541	1449	1449
query48	397	398	297	297
query49	566	395	291	291
query50	1109	424	348	348
query51	10327	11221	10498	10498
query52	86	87	74	74
query53	261	263	199	199
query54	276	230	214	214
query55	71	70	71	70
query56	297	279	303	279
query57	1016	1010	910	910
query58	293	276	258	258
query59	1535	1615	1411	1411
query60	322	306	260	260
query61	174	173	172	172
query62	407	331	271	271
query63	238	196	197	196
query64	2945	1156	931	931
query65	3900	3811	3817	3811
query66	1828	485	370	370
query67	28266	28208	28117	28117
query68	3296	1568	1024	1024
query69	412	318	261	261
query70	908	787	796	787
query71	377	348	319	319
query72	3161	2750	2310	2310
query73	860	733	407	407
query74	4669	4518	4310	4310
query75	2394	2322	2024	2024
query76	2331	1149	793	793
query77	331	372	276	276
query78	11175	11099	10652	10652
query79	2243	1167	784	784
query80	1432	542	482	482
query81	528	326	289	289
query82	588	150	112	112
query83	389	315	295	295
query84	281	156	132	132
query85	978	642	495	495
query86	410	230	219	219
query87	1797	1846	1703	1703
query88	3708	2781	2794	2781
query89	387	319	279	279
query90	1863	199	196	196
query91	205	192	163	163
query92	66	58	53	53
query93	1783	1510	1018	1018
query94	724	345	312	312
query95	808	497	493	493
query96	1113	793	364	364
query97	2482	2464	2355	2355
query98	209	197	195	195
query99	716	735	625	625
Total cold run time: 257527 ms
Total hot run time: 169512 ms

@hello-stephen

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

query1	0.00	0.00	0.00
query2	0.10	0.05	0.05
query3	0.25	0.14	0.13
query4	1.60	0.14	0.13
query5	0.23	0.22	0.22
query6	1.16	0.82	0.85
query7	0.04	0.01	0.00
query8	0.05	0.04	0.03
query9	0.38	0.32	0.31
query10	0.55	0.55	0.56
query11	0.18	0.13	0.14
query12	0.18	0.14	0.14
query13	0.46	0.45	0.46
query14	1.00	0.97	1.01
query15	0.62	0.57	0.58
query16	0.31	0.33	0.33
query17	1.06	1.09	1.07
query18	0.22	0.20	0.19
query19	2.10	1.94	2.01
query20	0.02	0.01	0.01
query21	15.44	0.22	0.15
query22	4.81	0.05	0.06
query23	16.12	0.30	0.12
query24	3.00	0.43	0.31
query25	0.11	0.07	0.03
query26	0.73	0.20	0.15
query27	0.05	0.03	0.03
query28	3.58	0.76	0.35
query29	12.47	4.02	3.18
query30	0.27	0.16	0.15
query31	2.76	0.56	0.32
query32	3.22	0.59	0.48
query33	3.26	3.31	3.18
query34	15.58	3.95	3.33
query35	3.21	3.20	3.20
query36	0.55	0.44	0.43
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.15
query41	0.09	0.03	0.02
query42	0.04	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 96.19 s
Total hot run time: 23.86 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 47.09% (162/344) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 12.50% (43/344) 🎉
Increment coverage report
Complete coverage report

@AntiTopQuark AntiTopQuark changed the title [WIP][feature](fe) Keep row binlog tablets colocated with base tablets [feature](fe) Keep row binlog tablets colocated with base tablets Aug 1, 2026
// Cross-link for a split base/row-binlog tablet pair. Legacy images do not
// contain this field and therefore keep the non-positive "not aligned" value.
@SerializedName(value = "ati")
protected long alignedTabletId = -1L;

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.

conflict design with #65810

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 introduces a second, incompatible representation of the base/row-binlog tablet relationship. PR #65810 already persists directional links: base.rowBinlogTabletId and companion.rowBinlogBaseTabletId, and its creation, sink, and report paths use those fields. This PR instead adds alignedTabletId and makes the locality scheduler depend on it. When the two changes are combined, tablets created by #65810 leave alignedTabletId unset, so the scheduler cannot resolve the pair. Please reuse #65810’s directional fields as the canonical model, or provide an explicit compatibility/migration layer instead of introducing a parallel persisted field.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, this has been addressed in the latest revision (d0182ef9ef) after rebasing on #65810.

This PR no longer introduces alignedTabletId / ati, separate row-binlog index states, or any other persisted tablet-pair representation. The locality, checker, and scheduler paths now use #65810’s canonical directional links:

  • companion -> base: getRowBinlogBaseTabletId()
  • base -> companion: getRowBinlogTabletId()

The companion index is identified by MaterializedIndex.isRowBinlog() with IndexState.NORMAL. The current Tablet.java diff does not add any pairing field; it only adds the binlogMissing replica filter. No new Gson or wire representation is introduced by this PR.

The Gson and locality tests were also updated for the directional fields and for old JSON without those optional fields. Since alignedTabletId never landed in the community branch and no deployed image was written with that model, there is no metadata migration to perform. If a declared row-binlog companion has missing or inconsistent directional links, it is treated as invalid metadata rather than falling back to a second representation.

FE unit tests have not been run locally yet; only static source, conflict, and history checks were completed. Could you please take another look?

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Row-binlog companion replicas can drift away from their base replicas during FE repair scheduling. This change evaluates companion health against effective base replicas, carries required backend and storage-path constraints into repair scheduling, protects complete replica pairs during deletion, and keeps ordinary colocate balancing statistics focused on queryable indexes.

### Release note

Keep row-binlog companion tablets on the same backend and storage path as their base tablets during FE repair scheduling.

### Check List (For Author)

- Test: Not run (per request; static conflict, source, and history checks only)
- Behavior changed: Yes. FE repair scheduling now preserves base and row-binlog backend and path locality.
- Does this need documentation: No
@AntiTopQuark
AntiTopQuark force-pushed the binlog_tablet_schedule branch from a231d97 to d0182ef Compare August 11, 2026 06:15
}

@Override
public void incrBinlogMissingCount() {

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.

consumeBinlogMissingRetry() or decrementBinlogMissingCount()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, thx~

@deardeng

Copy link
Copy Markdown
Contributor

[blocker] The row-binlog storage migration can race with an in-flight group load. The row-binlog builder retains a tablet shared pointer but does not register a separate transaction for that tablet. get_tablet_related_txns() only checks transaction-map keys and therefore cannot see either an active base-keyed group transaction or its nested attach_row_binlog. Migration reload replaces the tablet with a new UID/object, while commit/publish continues using the retained old object. Please add pair-aware transaction draining or lifetime migration locking, together with tests covering both pre-commit and committed-but-not-published windows.

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17564	3096	3088	3088
q2	2091	267	221	221
q3	10229	914	508	508
q4	4674	254	210	210
q5	7662	554	387	387
q6	140	117	96	96
q7	533	506	391	391
q8	9243	902	911	902
q9	3463	2404	2430	2404
q10	6516	856	726	726
q11	399	202	180	180
q12	609	254	202	202
q13	18143	1550	1175	1175
q14	157	150	140	140
q15	q16	433	401	370	370
q17	1364	903	793	793
q18	3030	2245	2226	2226
q19	1242	928	728	728
q20	374	279	216	216
q21	5643	1617	1821	1617
q22	331	265	235	235
Total cold run time: 93840 ms
Total hot run time: 16815 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3470	3332	3365	3332
q2	509	385	373	373
q3	2212	2402	2146	2146
q4	1202	1198	901	901
q5	2201	2132	2134	2132
q6	171	120	88	88
q7	1066	946	857	857
q8	1613	1409	1422	1409
q9	3151	3118	3104	3104
q10	1867	1811	1639	1639
q11	359	273	254	254
q12	451	431	348	348
q13	1485	1563	1146	1146
q14	178	164	161	161
q15	q16	391	393	347	347
q17	3623	3275	3218	3218
q18	4824	4406	4710	4406
q19	899	981	908	908
q20	1049	978	810	810
q21	3866	3205	3205	3205
q22	405	338	330	330
Total cold run time: 34992 ms
Total hot run time: 31114 ms

@hello-stephen

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

query5	4263	411	336	336
query6	371	141	122	122
query7	4968	429	238	238
query8	293	124	114	114
query9	8671	2886	2867	2867
query10	384	217	188	188
query11	5381	1018	901	901
query12	122	70	73	70
query13	1186	472	323	323
query14	6172	2203	2089	2089
query14_1	1986	1960	1977	1960
query15	174	122	111	111
query16	907	367	393	367
query17	750	441	353	353
query18	2338	319	237	237
query19	163	136	117	117
query20	72	72	69	69
query21	198	99	86	86
query22	5492	5412	5265	5265
query23	6683	6328	6073	6073
query23_1	6065	6083	6146	6083
query24	7246	1082	743	743
query24_1	764	754	758	754
query25	405	291	229	229
query26	1223	234	125	125
query27	2797	420	248	248
query28	4689	1494	1480	1480
query29	915	432	336	336
query30	249	154	126	126
query31	818	398	327	327
query32	129	72	76	72
query33	461	232	188	188
query34	1004	811	485	485
query35	404	400	339	339
query36	577	577	534	534
query37	125	79	69	69
query38	1011	847	803	803
query39	497	480	454	454
query39_1	444	462	467	462
query40	202	89	79	79
query41	53	52	51	51
query42	71	72	71	71
query43	241	242	212	212
query44	1007	550	545	545
query45	115	105	97	97
query46	791	831	544	544
query47	761	776	698	698
query48	300	310	233	233
query49	536	239	197	197
query50	773	271	199	199
query51	8365	8189	8285	8189
query52	67	71	60	60
query53	193	198	147	147
query54	208	227	166	166
query55	88	61	59	59
query56	213	176	175	175
query57	652	676	630	630
query58	205	157	184	157
query59	1234	1257	1114	1114
query60	251	196	190	190
query61	138	137	143	137
query62	360	220	183	183
query63	174	143	148	143
query64	2782	808	651	651
query65	1609	1727	1660	1660
query66	1763	268	200	200
query67	9942	9723	9691	9691
query68	3033	1180	709	709
query69	343	217	203	203
query70	642	633	603	603
query71	266	180	156	156
query72	2331	1753	1557	1557
query73	655	606	341	341
query74	2001	1202	1142	1142
query75	1194	1085	958	958
query76	2385	795	561	561
query77	257	261	207	207
query78	3840	3799	3198	3198
query79	2370	795	600	600
query80	1603	332	287	287
query81	492	155	131	131
query82	611	123	94	94
query83	280	211	193	193
query84	299	109	85	85
query85	792	355	311	311
query86	379	193	183	183
query87	1029	964	895	895
query88	2776	2092	2112	2092
query89	293	200	172	172
query90	2002	128	117	117
query91	133	118	98	98
query92	78	71	70	70
query93	1533	1125	707	707
query94	653	247	226	226
query95	524	260	310	260
query96	822	565	279	279
query97	1062	1040	1020	1020
query98	167	132	131	131
query99	413	344	309	309
Total cold run time: 178149 ms
Total hot run time: 82287 ms

@hello-stephen

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

query1	0.00	0.01	0.00
query2	0.07	0.03	0.04
query3	0.24	0.11	0.11
query4	1.60	0.09	0.09
query5	0.18	0.16	0.16
query6	1.27	0.70	0.72
query7	0.03	0.01	0.00
query8	0.05	0.03	0.03
query9	0.28	0.21	0.22
query10	0.35	0.37	0.36
query11	0.16	0.11	0.12
query12	0.14	0.11	0.12
query13	0.30	0.30	0.31
query14	0.45	0.45	0.43
query15	0.36	0.35	0.35
query16	0.21	0.23	0.22
query17	0.70	0.67	0.69
query18	0.18	0.16	0.18
query19	1.18	1.15	1.19
query20	0.01	0.01	0.01
query21	15.43	0.16	0.12
query22	5.08	0.04	0.05
query23	16.18	0.25	0.10
query24	3.08	0.31	0.24
query25	0.10	0.03	0.04
query26	0.72	0.17	0.12
query27	0.04	0.03	0.03
query28	3.60	0.57	0.28
query29	12.48	3.11	2.55
query30	0.25	0.11	0.12
query31	2.76	0.38	0.17
query32	3.52	0.30	0.23
query33	1.33	1.53	1.44
query34	15.41	2.17	1.80
query35	1.73	1.71	1.73
query36	0.45	0.31	0.29
query37	0.06	0.04	0.04
query38	0.04	0.04	0.03
query39	0.04	0.02	0.02
query40	0.12	0.08	0.07
query41	0.07	0.02	0.02
query42	0.03	0.03	0.02
query43	0.03	0.03	0.03
Total cold run time: 90.31 s
Total hot run time: 14.69 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.02% (34378/45222)
Line Coverage 61.02% (387619/635269)
Region Coverage 57.10% (324814/568865)
Branch Coverage 57.97% (148313/255841)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 11.97% (139/1161) 🎉
Increment coverage report
Complete coverage report

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

[blocker] The row-binlog storage migration can race with an in-flight group load. The row-binlog builder retains a tablet shared pointer but does not register a separate transaction for that tablet. get_tablet_related_txns() only checks transaction-map keys and therefore cannot see either an active base-keyed group transaction or its nested attach_row_binlog. Migration reload replaces the tablet with a new UID/object, while commit/publish continues using the retained old object. Please add pair-aware transaction draining or lifetime migration locking, together with tests covering both pre-commit and committed-but-not-published windows.

get_tablet_related_txns() now, when the queried tablet is not a map key, iterates each in-flight transaction and matches the attached row-binlog companion by tablet_id + tablet_uid:

if (!is_related) {
    for (const auto& tablet_txn : it.second) {
        const auto& attached_tablet = tablet_txn.second->attach_row_binlog.tablet;
        if (attached_tablet != nullptr &&
            attached_tablet->tablet_id() == tablet_info.tablet_id &&
            attached_tablet->tablet_uid() == tablet_info.tablet_uid) {
            is_related = true;
            break;
        }
    }
}

Because EngineStorageMigrationTask::_check_running_txns() relies on this call, the migration now correctly detects the active base-keyed group transaction through its nested attach_row_binlog, and blocks/waits until the group load drains — no reload can swap the UID/object out from under an in-flight commit or publish.

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

LGTM

@AntiTopQuark
AntiTopQuark requested a review from gavinchou August 28, 2026 09:07
@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

@gavinchou @morningman please review this PR, thx~

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

@yiguolei Hi, Please review this PR, thank you very much!

@gavinchou
gavinchou merged commit 5ae9e79 into apache:master Sep 1, 2026
37 of 38 checks passed
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. binlog reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Track incremental computation with row binlog, Table Stream, and MTMV

8 participants