Skip to content

[fix](replica) Resolve conflicting default replica properties#65836

Merged
deardeng merged 2 commits into
apache:masterfrom
deardeng:fix-allocation
Jul 23, 2026
Merged

[fix](replica) Resolve conflicting default replica properties#65836
deardeng merged 2 commits into
apache:masterfrom
deardeng:fix-allocation

Conversation

@deardeng

Copy link
Copy Markdown
Contributor

Problem Summary: ALTER TABLE updates to default.replication_allocation could leave the legacy default.replication_num property in table metadata. Because replica analysis checks replication_num first, SHOW CREATE TABLE and later consumers could observe the wrong default allocation. Remove the mutually exclusive property when applying an update, prefer replication_allocation when cleaning historical metadata, and cover allocation updates, metadata cleanup, and reverse numeric updates.

Release note

Fix conflicting default replica properties so the latest explicit replica setting is used.

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

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: ALTER TABLE updates to default.replication_allocation could leave the legacy default.replication_num property in table metadata. Because replica analysis checks replication_num first, SHOW CREATE TABLE and later consumers could observe the wrong default allocation. Remove the mutually exclusive property when applying an update, prefer replication_allocation when cleaning historical metadata, and cover allocation updates, metadata cleanup, and reverse numeric updates.

### Release note

Fix conflicting default replica properties so the latest explicit replica setting is used.

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.catalog.TablePropertyTest (10 passed)
    - cd fe && mvn checkstyle:check -pl fe-core (0 violations)
    - git diff --cached --check
- Behavior changed: Yes (conflicting default replica properties are removed so the latest explicit setting wins)
- 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?

@deardeng

Copy link
Copy Markdown
Contributor Author

run buildall

@deardeng

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: You've hit your usage limit. Visit https://chatgpt.com/codex/settings/usage to purchase more credits or try again at Jul 25th, 2026 3:35 AM.
Workflow run: https://github.com/apache/doris/actions/runs/29800963379

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17650	4085	4072	4072
q2	2015	342	197	197
q3	10243	1389	786	786
q4	4688	469	338	338
q5	7514	866	574	574
q6	188	171	136	136
q7	761	806	599	599
q8	9696	1523	1490	1490
q9	5971	4302	4313	4302
q10	6787	1720	1476	1476
q11	525	340	330	330
q12	752	559	461	461
q13	18107	3245	2694	2694
q14	259	268	235	235
q15	q16	770	772	701	701
q17	953	946	999	946
q18	6928	5828	5747	5747
q19	1487	1291	1105	1105
q20	805	697	565	565
q21	5852	2583	2324	2324
q22	428	355	300	300
Total cold run time: 102379 ms
Total hot run time: 29378 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4397	4375	4334	4334
q2	285	317	214	214
q3	4531	4938	4412	4412
q4	2074	2114	1361	1361
q5	4343	4210	4295	4210
q6	227	181	130	130
q7	1709	1889	1736	1736
q8	2455	2152	2070	2070
q9	7744	7736	7683	7683
q10	4721	4611	4209	4209
q11	578	426	384	384
q12	739	756	534	534
q13	3464	3538	2963	2963
q14	297	310	279	279
q15	q16	746	723	669	669
q17	1346	1316	1312	1312
q18	7821	7192	7074	7074
q19	1109	1065	1108	1065
q20	2177	2198	1931	1931
q21	5179	4452	4332	4332
q22	504	445	419	419
Total cold run time: 56446 ms
Total hot run time: 51321 ms

@hello-stephen

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

query5	4344	636	474	474
query6	459	266	209	209
query7	4867	611	335	335
query8	343	190	174	174
query9	8783	4088	4097	4088
query10	480	365	310	310
query11	5962	2316	2155	2155
query12	165	107	110	107
query13	1297	567	428	428
query14	6210	5205	4863	4863
query14_1	4248	4253	4212	4212
query15	214	200	181	181
query16	998	463	460	460
query17	1138	707	588	588
query18	2476	489	363	363
query19	205	190	148	148
query20	114	108	106	106
query21	234	162	134	134
query22	13514	13634	13316	13316
query23	17215	16473	16079	16079
query23_1	16247	16224	16073	16073
query24	8066	1745	1255	1255
query24_1	1282	1283	1284	1283
query25	536	423	386	386
query26	1320	370	205	205
query27	2554	570	368	368
query28	4408	1979	1971	1971
query29	1043	586	467	467
query30	333	260	226	226
query31	1132	1085	998	998
query32	113	60	60	60
query33	525	312	235	235
query34	1184	1129	634	634
query35	767	783	663	663
query36	1192	1191	1075	1075
query37	151	101	90	90
query38	1866	1700	1658	1658
query39	866	872	855	855
query39_1	859	825	832	825
query40	247	160	141	141
query41	65	64	63	63
query42	93	93	90	90
query43	319	319	279	279
query44	1399	746	780	746
query45	195	193	171	171
query46	1006	1154	765	765
query47	2112	2089	2035	2035
query48	407	397	253	253
query49	565	428	305	305
query50	1048	424	321	321
query51	10979	10834	10829	10829
query52	87	86	72	72
query53	255	272	194	194
query54	293	225	217	217
query55	108	71	69	69
query56	314	284	274	274
query57	1315	1277	1213	1213
query58	300	277	260	260
query59	1566	1604	1419	1419
query60	316	268	251	251
query61	153	146	154	146
query62	531	486	432	432
query63	242	202	196	196
query64	2816	997	832	832
query65	4726	4626	4636	4626
query66	1841	493	373	373
query67	29388	29231	29100	29100
query68	3154	1666	987	987
query69	413	302	248	248
query70	1052	976	943	943
query71	372	326	318	318
query72	3047	2678	2404	2404
query73	818	817	431	431
query74	5065	4913	4709	4709
query75	2536	2509	2125	2125
query76	2316	1178	768	768
query77	351	379	279	279
query78	11791	11772	11203	11203
query79	1308	1210	741	741
query80	645	544	452	452
query81	459	332	290	290
query82	235	157	118	118
query83	423	317	291	291
query84	290	156	131	131
query85	938	626	508	508
query86	326	288	282	282
query87	1811	1816	1748	1748
query88	3657	2797	2740	2740
query89	420	372	320	320
query90	2088	193	188	188
query91	213	187	162	162
query92	62	61	56	56
query93	1620	1610	995	995
query94	531	338	326	326
query95	814	488	560	488
query96	1046	844	354	354
query97	2607	2611	2512	2512
query98	219	206	201	201
query99	1100	1114	971	971
Total cold run time: 262589 ms
Total hot run time: 177657 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.10	0.04	0.04
query3	0.26	0.17	0.14
query4	1.61	0.12	0.13
query5	0.24	0.22	0.21
query6	1.20	1.05	1.04
query7	0.04	0.01	0.00
query8	0.06	0.03	0.03
query9	0.37	0.33	0.32
query10	0.54	0.56	0.54
query11	0.20	0.14	0.14
query12	0.18	0.14	0.14
query13	0.49	0.46	0.48
query14	1.02	1.00	1.02
query15	0.60	0.59	0.59
query16	0.32	0.32	0.31
query17	1.06	1.05	1.06
query18	0.22	0.22	0.21
query19	2.06	1.90	2.01
query20	0.01	0.01	0.01
query21	15.43	0.23	0.13
query22	4.86	0.06	0.05
query23	16.11	0.31	0.13
query24	2.95	0.43	0.35
query25	0.11	0.06	0.04
query26	0.72	0.20	0.14
query27	0.05	0.04	0.04
query28	3.57	0.95	0.51
query29	12.51	4.11	3.26
query30	0.28	0.15	0.17
query31	2.77	0.63	0.31
query32	3.21	0.59	0.49
query33	3.29	3.20	3.17
query34	15.60	4.25	3.50
query35	3.51	3.47	3.54
query36	0.56	0.44	0.42
query37	0.08	0.07	0.07
query38	0.05	0.03	0.03
query39	0.04	0.03	0.03
query40	0.18	0.17	0.15
query41	0.08	0.03	0.02
query42	0.04	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 96.62 s
Total hot run time: 24.77 s

@deardeng

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 result: request changes (2 blocking correctness/compatibility issues).

Critical checkpoint conclusions:

  • Goal and tests: The prospective SQL ALTER path now canonicalizes either default-replica spelling and same-version journal replay is symmetric, but the full latest-explicit-setting goal is not met. Historical image cleanup can discard a newer numeric value, and restore can bypass the new mutual-exclusion path. The added unit tests cover direct forward/reverse map updates and one allocation-newer deserialization case, but not a numeric-newer upgrade image or the restore setter.
  • Scope and abstraction: The patch is locally small, but the invariant is not centralized across all replica-property mutation APIs; that incompleteness causes the restore finding.
  • Concurrency and lifecycle: No new race or lock-order problem was found; live and replay mutation use the table write lock, while restore prepares staging metadata. The nontrivial image-deserialization and restore/replay lifecycle boundaries are where both accepted issues occur.
  • Persistence, compatibility, and parallel paths: SQL ALTER and its edit-log replay are prospectively equivalent. No storage-format or FE-BE protocol change is introduced. Historical snapshot precedence and mixed-version restore reconstruction are not compatible, as detailed inline.
  • Conditions and error handling: Single-key allocation and numeric updates remove the intended opposite key. The both-key allocation-wins condition is not safe for undated historical state. No additional exception/status-handling defect was found.
  • Configuration, data writes, FE-BE propagation, observability, and performance: No configuration, user-data transaction, or transmitted FE-BE variable is changed. The added map checks are constant time, and no new metric/log is warranted.
  • Test execution: Per the review-only runner contract, no local build or test was run. Current GitHub status shows COMPILE and Checkstyle passing, but FE UT, P0 Regression, and check_coverage_fe failing; the linked TeamCity logs require authentication, so those failures remain unresolved.
  • User focus: No additional user-provided focus was specified; the whole PR and the persistence/compatibility boundaries were reviewed.

Please address both inline findings and add the upgrade/restore coverage before merge.

Comment thread fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java Outdated
Comment thread fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java Outdated
### What problem does this PR solve?

Issue Number: None

Related PR: apache#65836

Problem Summary: Historical table metadata can contain both default replica properties without recording which value was written last. Unconditionally preferring replication allocation during image loading can therefore replace a newer numeric replica value. Restore also writes an allocation directly and can leave a legacy numeric property behind. Preserve the historical numeric-first image behavior, remove the numeric property from direct allocation setters, and make internal table replica updates persist the canonical allocation form.

### Release note

Preserve historical default replica behavior during upgrades and prevent restore from persisting conflicting replica properties.

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.catalog.TablePropertyTest (11 passed)
    - ./run-fe-ut.sh --run org.apache.doris.alter.InternalSchemaAlterTest (2 passed)
    - cd fe && mvn checkstyle:check -pl fe-core (0 violations)
    - git diff --cached --check
- Behavior changed: Yes. Historical images retain numeric-first precedence, while restore and future internal table updates persist a single canonical allocation property.
- Does this need documentation: No
@deardeng

Copy link
Copy Markdown
Contributor Author

run buildall

@deardeng

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 result: request changes (1 blocking correctness/compatibility issue).

Critical checkpoint conclusions:

  • Goal and tests: The current head fixes the two previously reported image-precedence and restore-setter issues and makes latest-explicit-setting behavior correct on a homogeneous current FE cluster. It does not preserve that behavior across mixed-version journal replay. Added tests cover both replacement directions, ambiguous image precedence, restore canonicalization, and partitioned/unpartitioned internal-table scaling, but not mixed-version replay/failover.
  • Scope and abstraction: The source change is small and focused, and current-version mutation is centralized. The durable transition remains incomplete because removed keys are absent from its payload.
  • Concurrency and lifecycle: No new race, lock-order, or heavy-under-lock issue was found; live and replay mutations use table write locks. The failure is at the rolling-upgrade replay/failover lifecycle boundary.
  • Persistence, compatibility, and parallel paths: Same-version leader/replay behavior is equivalent. Mixed versions are not: old and current FEs can derive different defaults from the same journal, and the same primitive is used by parallel partition/colocate transitions. This is the blocking inline issue.
  • Conditions, error handling, configuration, data writes, FE-BE propagation, observability, and performance: Caller canonicalization makes simultaneous-key current ALTER input unreachable; no additional status/exception defect was found. No configuration, user-data transaction, FE-BE field, storage format, metric, or material performance change is involved.
  • Test execution: Per the review-only runner contract, no local build or test was run. GitHub compilation and checkstyle passed at review time, but FE UT reported failure; its TeamCity log requires authentication, so the failure could not be classified here.
  • User focus: No additional user-provided focus was specified; the entire PR and its persistence/compatibility boundaries were reviewed.

Please make the removal replay-safe across supported rolling upgrades and add mixed-version replay/failover coverage before merge.

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17717	4217	4155	4155
q2	2064	342	206	206
q3	10244	1444	819	819
q4	4683	485	346	346
q5	7514	877	564	564
q6	183	181	143	143
q7	815	847	620	620
q8	9368	1642	1603	1603
q9	5580	4396	4410	4396
q10	6759	1749	1479	1479
q11	489	349	343	343
q12	739	586	470	470
q13	18145	3850	2775	2775
q14	273	265	251	251
q15	q16	801	790	711	711
q17	1020	967	932	932
q18	6942	5719	5499	5499
q19	1155	1256	977	977
q20	831	689	577	577
q21	5592	2613	2359	2359
q22	428	357	302	302
Total cold run time: 101342 ms
Total hot run time: 29527 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4411	4409	4394	4394
q2	310	343	226	226
q3	4600	4944	4384	4384
q4	2107	2185	1411	1411
q5	4460	4317	4365	4317
q6	240	181	135	135
q7	1773	2153	1840	1840
q8	2639	2298	2359	2298
q9	8069	8185	7808	7808
q10	4709	4705	4200	4200
q11	627	443	376	376
q12	764	784	553	553
q13	3334	3625	2925	2925
q14	287	300	272	272
q15	q16	700	743	652	652
q17	1403	1372	1560	1372
q18	8060	7554	7315	7315
q19	1207	1105	1153	1105
q20	2218	2217	1925	1925
q21	5342	4670	4871	4670
q22	529	485	414	414
Total cold run time: 57789 ms
Total hot run time: 52592 ms

@hello-stephen

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

query5	4322	622	483	483
query6	476	233	208	208
query7	4944	625	344	344
query8	337	187	177	177
query9	8782	4002	4036	4002
query10	472	359	303	303
query11	5908	2361	2139	2139
query12	164	102	98	98
query13	1245	596	415	415
query14	6243	5226	4907	4907
query14_1	4258	4256	4253	4253
query15	211	201	182	182
query16	1007	478	449	449
query17	958	717	585	585
query18	2434	474	348	348
query19	220	194	154	154
query20	117	127	106	106
query21	239	156	136	136
query22	13678	13740	13337	13337
query23	17488	16466	16145	16145
query23_1	16171	16210	16154	16154
query24	7774	1752	1263	1263
query24_1	1281	1292	1270	1270
query25	579	461	386	386
query26	1325	377	229	229
query27	2561	561	384	384
query28	4518	2010	2013	2010
query29	1073	638	490	490
query30	349	265	230	230
query31	1131	1094	989	989
query32	107	63	61	61
query33	522	326	256	256
query34	1174	1120	637	637
query35	771	778	675	675
query36	1232	1156	1060	1060
query37	153	106	92	92
query38	1878	1709	1698	1698
query39	873	867	843	843
query39_1	835	840	839	839
query40	238	160	141	141
query41	64	61	63	61
query42	92	95	90	90
query43	317	325	273	273
query44	1430	770	764	764
query45	191	188	183	183
query46	1006	1141	706	706
query47	2157	2125	2016	2016
query48	397	405	284	284
query49	583	415	311	311
query50	1039	423	347	347
query51	10546	10452	10736	10452
query52	86	90	79	79
query53	264	265	202	202
query54	274	237	214	214
query55	77	69	64	64
query56	298	300	303	300
query57	1312	1299	1211	1211
query58	279	254	257	254
query59	1580	1642	1413	1413
query60	305	281	256	256
query61	150	152	153	152
query62	534	495	431	431
query63	244	196	202	196
query64	2827	1077	916	916
query65	4708	4657	4655	4655
query66	1848	564	393	393
query67	29379	29336	29062	29062
query68	3253	1444	877	877
query69	412	305	272	272
query70	1055	970	928	928
query71	406	348	311	311
query72	3042	2695	2313	2313
query73	814	768	442	442
query74	5053	4900	4718	4718
query75	2550	2511	2126	2126
query76	2327	1166	806	806
query77	339	384	273	273
query78	11936	11919	11357	11357
query79	1505	1163	760	760
query80	1306	554	461	461
query81	542	338	286	286
query82	601	158	121	121
query83	379	331	312	312
query84	333	158	128	128
query85	972	619	523	523
query86	431	291	278	278
query87	1820	1829	1755	1755
query88	3685	2776	2731	2731
query89	434	373	320	320
query90	1922	195	193	193
query91	202	188	157	157
query92	59	62	53	53
query93	1670	1550	984	984
query94	727	360	296	296
query95	775	587	488	488
query96	1030	794	344	344
query97	2630	2637	2501	2501
query98	214	206	201	201
query99	1093	1111	972	972
Total cold run time: 263682 ms
Total hot run time: 177462 ms

@hello-stephen

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

query1	0.00	0.01	0.00
query2	0.10	0.04	0.04
query3	0.26	0.13	0.14
query4	1.61	0.14	0.15
query5	0.26	0.22	0.21
query6	1.23	1.07	1.07
query7	0.04	0.01	0.01
query8	0.05	0.03	0.03
query9	0.39	0.31	0.30
query10	0.56	0.58	0.57
query11	0.20	0.13	0.14
query12	0.18	0.14	0.13
query13	0.46	0.46	0.48
query14	1.02	1.01	1.00
query15	0.61	0.59	0.59
query16	0.33	0.33	0.32
query17	1.12	1.10	1.11
query18	0.22	0.21	0.21
query19	1.98	2.04	1.97
query20	0.02	0.01	0.01
query21	15.44	0.20	0.13
query22	4.93	0.05	0.05
query23	16.14	0.32	0.12
query24	2.89	0.42	0.32
query25	0.11	0.04	0.04
query26	0.72	0.20	0.14
query27	0.04	0.04	0.03
query28	3.54	0.92	0.52
query29	12.47	4.05	3.25
query30	0.27	0.15	0.16
query31	2.77	0.59	0.31
query32	3.22	0.58	0.49
query33	3.24	3.22	3.30
query34	15.46	4.17	3.50
query35	3.55	3.55	3.50
query36	0.55	0.43	0.43
query37	0.09	0.06	0.07
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.19	0.17	0.17
query41	0.08	0.03	0.02
query42	0.04	0.02	0.02
query43	0.04	0.03	0.04
Total cold run time: 96.51 s
Total hot run time: 24.99 s

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

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

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

@deardeng
deardeng merged commit 8a1bf78 into apache:master Jul 23, 2026
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants