Skip to content

[opt](planner) Enable Nereids distribute planner after upgrade - #66604

Open
924060929 wants to merge 1 commit into
apache:masterfrom
924060929:agent/enable-nereids-distribute-planner-on-upgrade
Open

[opt](planner) Enable Nereids distribute planner after upgrade#66604
924060929 wants to merge 1 commit into
apache:masterfrom
924060929:agent/enable-nereids-distribute-planner-on-upgrade

Conversation

@924060929

@924060929 924060929 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: New installations default enable_nereids_distribute_planner to true, but clusters upgrading from a variable version below 400 restore the persisted global session default from their image. Clusters that persisted the previous false default would therefore continue using the legacy distribute planner after upgrading to 4.0. Add enable_nereids_distribute_planner to the existing variable-version-400 migration so that the 3.x-to-4.0 upgrade enables it. The migration uses the existing global-variable edit-log path and does not change clusters whose variable version is already 400.

Release note

Clusters upgrading to 4.0 now enable the Nereids distribute planner by default.

Check List (For Author)

  • Test: Unit Test
    • VariableMgrTest#testEnableNereidsDistributePlannerAfterUpgrade
    • FE Checkstyle for fe-core
  • Behavior changed: Yes. Clusters upgrading from a variable version below 400 default to the Nereids distribute planner.
  • 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?

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: New installations default enable_nereids_distribute_planner to true, but clusters upgrading from a variable version below 400 restore the persisted global session default from their image. Clusters that persisted the previous false default would therefore continue using the legacy distribute planner after upgrading to 4.0. Add enable_nereids_distribute_planner to the existing variable-version-400 migration so that the 3.x-to-4.0 upgrade enables it. The migration uses the existing global-variable edit-log path and does not change clusters whose variable version is already 400.

### Release note

Clusters upgrading to 4.0 now enable the Nereids distribute planner by default.

### Check List (For Author)

- Test: Unit Test
    - `VariableMgrTest#testEnableNereidsDistributePlannerAfterUpgrade`
    - FE Checkstyle for fe-core
- Behavior changed: Yes. Clusters upgrading from a variable version below 400 default to the Nereids distribute planner.
- Does this need documentation: No
@924060929
924060929 force-pushed the agent/enable-nereids-distribute-planner-on-upgrade branch from 05770e2 to 2e5e4cc Compare August 10, 2026 07:38
@924060929
924060929 marked this pull request as ready for review August 10, 2026 07:38
@924060929

Copy link
Copy Markdown
Contributor Author

run buildall

@924060929

Copy link
Copy Markdown
Contributor Author

/review

@morrySnow morrySnow changed the title [improvement](fe) Enable Nereids distribute planner after upgrade [opt](planner) Enable Nereids distribute planner after upgrade Aug 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added approved Indicates a PR has been approved by one committer. reviewed labels Aug 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@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. The patch is focused, but it does not update the released upgrade state it is meant to fix, and the new test leaves durable global-variable side effects that a later checkpoint can replay.

Critical checkpoint conclusions:

  • Goal and proof: The intended result is to enable the Nereids distribute planner for upgraded clusters. The implementation only handles a direct version-300-to-this-head path; released 4.0/4.1 clusters already persist version 400, so the real already-upgraded state is unchanged. The test starts at 300 and therefore does not prove the affected path.
  • Scope and clarity: The production change is small and reuses the established migration helper, but it is attached to a spent version fence. The test is otherwise focused, but invoking the real durable migration without isolating its journal writes creates order-dependent global state.
  • Concurrency: Migration runs during master promotion after journal replay, before serving readiness, and each update uses the existing VariableMgr write lock. No new lock-order, deadlock, or concurrent-session mutation issue was found.
  • Lifecycle: This is a one-shot persisted migration. Target-before-version ordering is idempotent across crashes, but the already-consumed 400 lifecycle gate prevents the target update from running for existing 4.x images/journals.
  • Configuration: No new configuration item is introduced; the existing global session default remains dynamically settable after the one-time migration.
  • Compatibility and parallel paths: The variable and edit-log opcode already exist, and the sole production caller plus follower replay path were inspected. A fresh 401 fence is rolling-upgrade safe because older 4.x FEs can replay the known variable and the integer version, then skip their older < 400 migrations. No alternate production path repairs the current omission.
  • Special condition: The new < VARIABLE_VERSION_400 placement is the blocking condition. It needs a new version fence rather than <= 400 or an unconditional rewrite, so later administrator changes remain preserved.
  • Test coverage and results: The new assertions are correct for the version-300 scenario but miss version 400 to the new fence and a post-migration no-op. The test also journals unrelated static-global changes that its in-memory finally cannot survive a later checkpoint replay. No build or test was run in this review-only runner, per its instructions.
  • Observability: Existing upgrade logs identify the source version, variable, and value; no additional metric is needed for this one-time path.
  • Persistence and failover: OP_GLOBAL_VARIABLE_V2 write/replay is symmetric, and logging the target before the version gives safe retry behavior. The defect is reachability, not serialization or failover ordering.
  • Data writes and FE/BE propagation: No transaction/data-write, storage-format, or new FE-to-BE variable surface is introduced.
  • Performance and other risks: The work is constant and upgrade-only, with no hot-path cost. No additional distinct correctness, compatibility, lifecycle, or performance issue survived two review rounds.

User focus: no additional focus was provided; the full two-file PR was reviewed.

VariableMgr.refreshDefaultSessionVariables(updateInfo,
SessionVariable.ENABLE_SQL_CACHE,
String.valueOf(true));
VariableMgr.refreshDefaultSessionVariables(updateInfo,

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 extends a migration fence that released clusters have already consumed. A 3.1 image can contain planner=false/version=300; released 4.0 migrates that image to version 400 without changing the flag. On a later upgrade, replay restores false/400 before forceUpdateVariables(), so 400 < 400 is false and this assignment never runs. Please add a fresh one-shot version (for example, VARIABLE_VERSION_401, made current, with this assignment under < 401) and make the regression start from version 400 plus planner=false. Otherwise already-upgraded clusters remain on the legacy planner.

defaultSessionVariable.setEnableNereidsDistributePlanner(false);
GlobalVariable.variableVersion = GlobalVariable.VARIABLE_VERSION_300;

VariableMgr.forceUpdateVariables();

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 test journals the real version-400 migration, including unrelated ANSI/type-coercion changes, but finally restores them only in memory. If it precedes testGlobalVariablePersist, that test's edit_log_roll_num=1 finalizes these records and its manual checkpoint replays them. Checkpoint SessionVariable objects are isolated, but GlobalVariable contexts still target shared statics (obj=null), so ANSI/type-coercion become false again after this cleanup and leak into later methods. Please use a scoped edit-log spy/stub restored in finally, or otherwise make cleanup durable.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

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

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17764	3983	4010	3983
q2	2074	335	200	200
q3	10198	1433	818	818
q4	4685	467	342	342
q5	7519	841	553	553
q6	182	175	138	138
q7	750	806	606	606
q8	9343	1463	1444	1444
q9	5315	4071	4092	4071
q10	6714	1618	1357	1357
q11	511	350	331	331
q12	724	573	464	464
q13	18117	3259	2751	2751
q14	261	262	254	254
q15	q16	735	732	657	657
q17	1043	1045	954	954
q18	6569	5633	5561	5561
q19	1316	1202	1043	1043
q20	820	738	559	559
q21	6415	2819	2675	2675
q22	473	386	322	322
Total cold run time: 101528 ms
Total hot run time: 29083 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5069	4677	4723	4677
q2	321	319	219	219
q3	5020	5358	4675	4675
q4	2261	2248	1455	1455
q5	4578	4786	4501	4501
q6	234	173	127	127
q7	1832	1754	1496	1496
q8	2425	2145	2161	2145
q9	7301	7003	6787	6787
q10	4207	4238	3810	3810
q11	521	390	350	350
q12	705	713	508	508
q13	3066	3340	2807	2807
q14	270	285	249	249
q15	q16	709	679	599	599
q17	1263	1239	1256	1239
q18	12043	10976	11822	10976
q19	1091	1071	1086	1071
q20	2198	2204	1913	1913
q21	5371	4605	4587	4587
q22	531	443	401	401
Total cold run time: 61016 ms
Total hot run time: 54592 ms

@hello-stephen

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

query5	4311	582	448	448
query6	456	231	203	203
query7	4899	614	318	318
query8	317	166	146	146
query9	8753	4044	4058	4044
query10	493	359	324	324
query11	5825	2172	2032	2032
query12	152	100	95	95
query13	1262	618	451	451
query14	6060	4280	3992	3992
query14_1	3829	3802	3796	3796
query15	200	192	171	171
query16	989	471	430	430
query17	957	692	545	545
query18	2434	462	337	337
query19	210	183	146	146
query20	101	104	101	101
query21	227	159	134	134
query22	13019	12907	12897	12897
query23	15694	14959	14605	14605
query23_1	14520	14593	14711	14593
query24	7639	1690	1240	1240
query24_1	1263	1270	1254	1254
query25	561	456	383	383
query26	1315	358	203	203
query27	2640	577	394	394
query28	4567	2078	2008	2008
query29	1075	604	459	459
query30	334	257	224	224
query31	1165	1113	1042	1042
query32	107	62	59	59
query33	518	299	254	254
query34	1173	1143	648	648
query35	730	737	638	638
query36	771	779	707	707
query37	158	109	99	99
query38	1841	1780	1683	1683
query39	832	811	795	795
query39_1	788	788	783	783
query40	244	170	144	144
query41	65	64	61	61
query42	94	96	91	91
query43	319	323	279	279
query44	1434	772	774	772
query45	185	175	173	173
query46	1089	1194	741	741
query47	1553	1545	1450	1450
query48	412	420	302	302
query49	591	411	310	310
query50	1145	456	332	332
query51	10722	10630	10572	10572
query52	88	96	79	79
query53	253	268	200	200
query54	295	246	220	220
query55	75	73	68	68
query56	329	299	302	299
query57	1024	1009	913	913
query58	281	254	258	254
query59	1566	1624	1401	1401
query60	314	271	235	235
query61	154	146	150	146
query62	398	319	267	267
query63	234	195	204	195
query64	2858	1016	836	836
query65	3810	3806	3796	3796
query66	1826	475	375	375
query67	20081	20202	20088	20088
query68	3316	1572	1058	1058
query69	413	295	255	255
query70	885	808	772	772
query71	378	331	304	304
query72	3109	2801	2540	2540
query73	873	773	411	411
query74	4613	4527	4310	4310
query75	2389	2355	2020	2020
query76	2356	1143	776	776
query77	360	378	289	289
query78	11252	11065	10457	10457
query79	1425	1181	765	765
query80	698	622	467	467
query81	454	327	287	287
query82	628	181	141	141
query83	410	333	297	297
query84	326	163	131	131
query85	947	624	532	532
query86	326	234	219	219
query87	1953	1951	1828	1828
query88	3717	2768	2777	2768
query89	389	339	287	287
query90	1964	205	193	193
query91	203	193	164	164
query92	64	62	57	57
query93	1648	1605	1050	1050
query94	543	351	305	305
query95	817	480	548	480
query96	1088	838	376	376
query97	2443	2474	2373	2373
query98	199	193	183	183
query99	731	728	617	617
Total cold run time: 244830 ms
Total hot run time: 158738 ms

@hello-stephen

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

query1	0.01	0.00	0.01
query2	0.09	0.05	0.05
query3	0.28	0.14	0.13
query4	1.60	0.14	0.13
query5	0.24	0.22	0.22
query6	1.16	0.83	0.83
query7	0.05	0.01	0.01
query8	0.06	0.03	0.04
query9	0.37	0.32	0.33
query10	0.53	0.58	0.58
query11	0.20	0.13	0.13
query12	0.17	0.15	0.14
query13	0.48	0.46	0.47
query14	0.99	0.98	0.97
query15	0.60	0.59	0.59
query16	0.32	0.32	0.31
query17	1.07	1.07	1.08
query18	0.22	0.20	0.20
query19	2.03	2.00	1.98
query20	0.02	0.01	0.01
query21	15.43	0.22	0.15
query22	4.82	0.05	0.06
query23	16.13	0.30	0.12
query24	3.03	0.43	0.32
query25	0.13	0.05	0.04
query26	0.72	0.19	0.16
query27	0.05	0.04	0.04
query28	3.49	0.79	0.33
query29	12.47	4.02	3.17
query30	0.28	0.15	0.16
query31	2.77	0.55	0.32
query32	3.21	0.58	0.49
query33	3.16	3.12	3.24
query34	15.46	3.95	3.32
query35	3.22	3.23	3.25
query36	0.59	0.45	0.44
query37	0.09	0.07	0.07
query38	0.05	0.04	0.03
query39	0.04	0.03	0.02
query40	0.17	0.15	0.14
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.04	0.04
Total cold run time: 95.97 s
Total hot run time: 23.97 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 0.00% (0/14) 🎉
Increment coverage report
Complete coverage report

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. dev/4.0.x dev/4.1.x dev/4.2.x reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants