Skip to content

[opt](point query) Optimize backend path collection for point queries - #67151

Merged
morrySnow merged 1 commit into
apache:masterfrom
zyp-V:op_point_query
Aug 31, 2026
Merged

[opt](point query) Optimize backend path collection for point queries#67151
morrySnow merged 1 commit into
apache:masterfrom
zyp-V:op_point_query

Conversation

@zyp-V

@zyp-V zyp-V commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Point-query planning built alive disk path sets for every backend even though tablet pruning leaves only a small set of replica backends. This made planning work grow with cluster size. Build the full map for regular scans and collect paths only for the selected tablet replica backends for point queries. Use the current backend snapshot API so the backport remains compatible with cloud and remote OLAP tables.

Release note

Reduce point-query planning overhead in clusters with many backends.

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?

@morrySnow morrySnow changed the title [improvement](fe) Optimize backend path collection for point queries [opt](point query) Optimize backend path collection for point queries Aug 26, 2026
@zyp-V

zyp-V commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@HonestManXin

Copy link
Copy Markdown
Contributor

/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.

I found two actionable issues in the new point-query-only collection path:

  1. The helper and Tablet.getQueryableReplicas() can observe different replica snapshots after planning locks are released, allowing a newly published distinct-backend replica to bypass the dead-path tier.
  2. Cloud replicas have no disk path hash, but the helper still performs an additional compute-group/backend placement resolution whose result cannot affect cloud queryability.

Critical checkpoint conclusions:

  • Goal and proof: The patch does reduce stable local/remote point-query collection from all cluster backends to selected replica backends, and the regular-scan path remains unchanged. The new unit test correctly proves helper-level narrowing and alive/offline disk-set construction, but it does not cover the accepted concurrency interval or cloud call count.
  • Scope and clarity: The source change is focused, but the two issues above need correction before the optimization is safe and complete across supported modes.
  • Concurrency and lifecycle: New maps/sets are method-local and introduce no ownership, lock-order, or release problem. The material concurrency issue is the unlocked point-query reevaluation using two independently mutable LocalTablet snapshots.
  • Correctness and error handling: Visible-version checks, replica state/version checks, backend availability, resource tags, and downstream error propagation are otherwise preserved. Stable local/remote identity and missing-backend behavior match the previous path; cloud dynamic identity does not change disk-path correctness because CloudReplica.pathHash is always -1.
  • Compatibility and parallel paths: Non-point scans retain the full backend path map. Remote OLAP uses its catalog-scoped backend snapshot. No FE/BE protocol, storage-format, rolling-upgrade, configuration, persistence/EditLog, transaction, data-write, or master-failover change is involved.
  • Performance: The main asymptotic improvement is valid for local/remote point queries. The extra cloud resolution is nevertheless provably unused hot-path work; this review does not claim the whole PR is net slower than its baseline.
  • Tests and observability: Existing logs/retries remain available, but retry only mitigates the newly admitted dead-path candidate. Add a latch-based snapshot-publication test and a cloud resolution call-count test. No local build or test was run because the review runner instructions prohibit builds.
  • User focus: No additional focus point was supplied; the complete PR was reviewed.

Review convergence completed in two rounds. The second full review and both focused rechecks returned NO_NEW_VALUABLE_FINDINGS; no other unresolved issue remains.

Comment thread fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
Comment thread fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17555	3015	3015	3015
q2	2117	255	215	215
q3	10202	848	525	525
q4	4671	249	196	196
q5	7683	560	379	379
q6	136	120	95	95
q7	543	512	386	386
q8	9234	851	895	851
q9	3501	2431	2381	2381
q10	6506	851	719	719
q11	395	195	181	181
q12	647	260	196	196
q13	18099	1534	1162	1162
q14	160	148	139	139
q15	q16	435	389	367	367
q17	1270	825	769	769
q18	3074	2248	2205	2205
q19	1110	884	776	776
q20	370	279	197	197
q21	5282	1651	1888	1651
q22	326	271	223	223
Total cold run time: 93316 ms
Total hot run time: 16628 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3385	3355	3312	3312
q2	505	399	368	368
q3	2251	2401	2175	2175
q4	1194	1162	879	879
q5	2182	2113	2117	2113
q6	172	124	91	91
q7	1036	931	849	849
q8	1595	1397	1390	1390
q9	3111	3097	3072	3072
q10	1825	1789	1644	1644
q11	352	268	251	251
q12	447	424	335	335
q13	1483	1518	1166	1166
q14	174	172	167	167
q15	q16	388	394	353	353
q17	3641	3328	3305	3305
q18	4852	4409	4692	4409
q19	1393	814	943	814
q20	969	945	824	824
q21	3725	3030	3226	3030
q22	405	342	310	310
Total cold run time: 35085 ms
Total hot run time: 30857 ms

@hello-stephen

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

query5	4253	406	345	345
query6	420	132	121	121
query7	4924	374	231	231
query8	306	123	117	117
query9	8700	2834	2872	2834
query10	395	216	183	183
query11	5394	1015	940	940
query12	119	70	67	67
query13	1189	453	320	320
query14	6122	2187	2072	2072
query14_1	1954	1921	1942	1921
query15	181	121	115	115
query16	939	378	359	359
query17	820	448	362	362
query18	2343	330	238	238
query19	172	142	109	109
query20	70	69	72	69
query21	207	103	86	86
query22	5349	5330	5305	5305
query23	6620	6099	6076	6076
query23_1	5884	6180	5970	5970
query24	7306	1068	768	768
query24_1	775	794	775	775
query25	441	311	259	259
query26	963	228	132	132
query27	2775	390	253	253
query28	4697	1522	1510	1510
query29	929	447	362	362
query30	275	160	130	130
query31	841	410	327	327
query32	131	71	76	71
query33	500	208	170	170
query34	1003	839	499	499
query35	397	398	345	345
query36	573	529	536	529
query37	126	75	71	71
query38	1020	853	797	797
query39	488	493	452	452
query39_1	438	439	453	439
query40	197	87	77	77
query41	52	50	50	50
query42	73	71	74	71
query43	241	237	206	206
query44	1017	542	554	542
query45	107	104	95	95
query46	780	866	528	528
query47	743	746	692	692
query48	313	306	228	228
query49	545	228	185	185
query50	735	263	188	188
query51	7913	8026	8036	8026
query52	69	68	63	63
query53	191	196	144	144
query54	253	204	148	148
query55	70	59	61	59
query56	206	168	153	153
query57	681	668	656	656
query58	259	176	160	160
query59	1256	1222	1072	1072
query60	256	183	181	181
query61	118	118	113	113
query62	386	201	181	181
query63	168	141	143	141
query64	2286	648	563	563
query65	1602	1623	1554	1554
query66	1849	271	207	207
query67	10161	9764	9547	9547
query68	2775	1200	768	768
query69	396	215	198	198
query70	657	616	600	600
query71	248	167	162	162
query72	2394	1756	1544	1544
query73	671	603	327	327
query74	1573	1206	1130	1130
query75	1155	1095	939	939
query76	2302	736	559	559
query77	249	263	218	218
query78	3852	3687	3203	3203
query79	1350	911	562	562
query80	1204	335	290	290
query81	487	159	134	134
query82	676	136	103	103
query83	286	209	200	200
query84	306	118	92	92
query85	885	362	296	296
query86	441	170	174	170
query87	1001	967	884	884
query88	2774	2103	2102	2102
query89	297	194	172	172
query90	1979	127	128	127
query91	132	117	102	102
query92	78	63	66	63
query93	1383	1194	716	716
query94	673	256	218	218
query95	543	328	225	225
query96	810	587	281	281
query97	1035	1015	1043	1015
query98	145	133	133	133
query99	435	351	299	299
Total cold run time: 175240 ms
Total hot run time: 81550 ms

@hello-stephen

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

query1	0.01	0.00	0.00
query2	0.07	0.03	0.03
query3	0.25	0.11	0.10
query4	1.61	0.10	0.10
query5	0.17	0.16	0.16
query6	1.20	0.70	0.68
query7	0.04	0.01	0.00
query8	0.05	0.03	0.03
query9	0.31	0.21	0.22
query10	0.35	0.33	0.34
query11	0.16	0.11	0.12
query12	0.15	0.12	0.12
query13	0.29	0.30	0.31
query14	0.45	0.45	0.45
query15	0.36	0.35	0.34
query16	0.21	0.22	0.20
query17	0.68	0.63	0.65
query18	0.19	0.17	0.17
query19	1.24	1.18	1.08
query20	0.02	0.02	0.01
query21	15.44	0.17	0.12
query22	5.07	0.04	0.04
query23	16.14	0.25	0.10
query24	3.02	0.32	0.26
query25	0.12	0.03	0.05
query26	0.70	0.16	0.12
query27	0.03	0.03	0.03
query28	3.65	0.59	0.28
query29	12.44	3.14	2.52
query30	0.25	0.10	0.13
query31	2.76	0.37	0.17
query32	3.51	0.29	0.23
query33	1.51	1.43	1.40
query34	15.40	2.22	1.77
query35	1.77	1.71	1.71
query36	0.48	0.29	0.28
query37	0.06	0.04	0.04
query38	0.05	0.03	0.03
query39	0.03	0.02	0.03
query40	0.11	0.08	0.07
query41	0.07	0.02	0.02
query42	0.03	0.02	0.02
query43	0.04	0.03	0.02
Total cold run time: 90.49 s
Total hot run time: 14.43 s

morrySnow
morrySnow previously approved these changes Aug 26, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Point-query planning built alive disk path sets for every backend even though tablet pruning leaves only a small set of replica backends. This made planning work grow with cluster size. Build the full map for regular scans and collect paths only for the selected tablet replica backends for point queries. Use the current backend snapshot API so the backport remains compatible with cloud and remote OLAP tables.

Backport of a209ce4b876c38aea0ea7d1f6c84e6e7b14c5a39.

### Release note

Reduce point-query planning overhead in clusters with many backends.

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.planner.OlapScanNodeTest#testPointQueryBackendAlivePathsOnlyUseSelectedTabletBackends
- Behavior changed: No. Only point-query planning work is reduced.
- Does this need documentation: No
@HonestManXin

Copy link
Copy Markdown
Contributor

/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.

This head still contains two actionable issues already reported in live inline threads:

  1. The helper and Tablet.getQueryableReplicas() can observe different replica snapshots after planning locks are released, allowing a newly published distinct-backend replica to bypass offline-path demotion.
  2. Cloud replicas have no disk path hash, but the helper still performs an additional compute-group/backend placement resolution whose result cannot affect cloud queryability.

No new inline comment is added because both issues are already anchored on the current head; duplicating them would violate the review's deduplication requirement.

Critical checkpoint conclusions:

  • Goal and proof: For stable local and remote metadata, the patch reduces point-query disk-path collection from every cluster backend to the selected tablet's replica backends, while regular scans retain full-backend collection. The helper-level unit test proves selected/unrelated/missing backend behavior and alive/offline disk-set construction, but not the two failing production scenarios above.
  • Scope and clarity: The refactor is small and focused. It is not ready to approve until the replica snapshot and pathless-cloud cases are corrected.
  • Concurrency: LocalTablet publishes replica lists with volatile copy-on-write snapshots and lazy point-query evaluation runs without the planning table lock. The new helper and queryability filter take separate snapshots; that is the material race. No new shared map/set, lock-order, deadlock, or heavy-under-lock issue was found.
  • Lifecycle: The added maps and sets are method-local. No static initialization, ownership cycle, cleanup, or release-order change applies.
  • Configuration: No configuration item or dynamic-reload behavior is added or changed.
  • Compatibility: No FE/BE protocol, function symbol, storage format, serialized metadata, or rolling-upgrade contract changes. Cloud and remote OLAP subclasses remain in scope; cloud has the redundant placement work described above.
  • Parallel paths: Non-point scans preserve the prior full backend path map. Remote OLAP continues to use its catalog-scoped backend snapshot. No other functionally parallel scan path requires the same code change.
  • Conditions, correctness, and error handling: Visible-version checks, replica state/version checks, disk-path demotion, backend availability, resource-tag filtering, and downstream failures are otherwise preserved. Backend-map refresh drift predates this diff; the new missing-path case is specifically the two-replica-snapshot race already reported.
  • Test coverage: The added JUnit test is deterministic and its expected values are correct by inspection, but it calls the helper directly. Add a latch-based publication test through queryability filtering and a cloud placement-resolution call-count test. No separate third test-derived defect was found.
  • Test execution: No local build or test was run because the review-runner instructions prohibit builds. The live check rollup shows FE CheckStyle and the visible formatting, license, secret, and changed-file checks succeeding.
  • Observability: Existing logs and retry behavior remain available; retry mitigates but does not remove the offline-path candidate race. No new metric or log is otherwise required.
  • Persistence and transactions: No EditLog, replay, master-failover, transaction, or persisted-state change applies.
  • Data writes and FE/BE variables: No data-write atomicity, crash recovery, memory ownership, or new FE-to-BE variable propagation concern applies.
  • Performance: The intended asymptotic improvement is valid for stable local/remote point queries. The extra cloud placement resolution is provably unused hot-path work. Supported successful point queries enforce a single tablet/partition, so no separate per-partition rescan regression was substantiated.
  • Other issues and user focus: No additional valuable issue survived the final sweep. No additional user-provided focus point was supplied; the complete PR was reviewed.

Review convergence completed in one round: two independent full reviews and the separate risk-focused review all returned NO_NEW_VALUABLE_FINDINGS after missed-issue rechecks. Every candidate was independently verified, deduplicated, accepted, or dismissed, and no unresolved point remains.

@zyp-V

zyp-V commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17556	3037	2987	2987
q2	2094	265	229	229
q3	10236	869	505	505
q4	4671	254	200	200
q5	7671	542	385	385
q6	133	117	100	100
q7	545	493	384	384
q8	9233	910	862	862
q9	3512	2389	2371	2371
q10	6493	835	704	704
q11	387	194	178	178
q12	605	258	201	201
q13	18137	1529	1166	1166
q14	157	150	139	139
q15	q16	420	401	363	363
q17	1444	886	845	845
q18	3166	2238	2202	2202
q19	1114	861	724	724
q20	356	296	202	202
q21	4798	1728	1832	1728
q22	325	264	227	227
Total cold run time: 93053 ms
Total hot run time: 16702 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3369	3328	3299	3299
q2	499	401	373	373
q3	2191	2377	2139	2139
q4	1186	1154	884	884
q5	2170	2098	2103	2098
q6	166	118	85	85
q7	1007	919	864	864
q8	1590	1395	1375	1375
q9	3108	3079	3057	3057
q10	1846	1776	1597	1597
q11	357	268	255	255
q12	449	426	340	340
q13	1471	1503	1152	1152
q14	165	171	162	162
q15	q16	384	400	377	377
q17	3553	3285	3216	3216
q18	4804	4400	4726	4400
q19	865	819	813	813
q20	1125	978	870	870
q21	3837	3124	3286	3124
q22	389	343	329	329
Total cold run time: 34531 ms
Total hot run time: 30809 ms

@hello-stephen

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

query5	4286	408	342	342
query6	397	146	157	146
query7	4887	410	236	236
query8	293	129	116	116
query9	8701	2878	2878	2878
query10	403	231	186	186
query11	5384	1036	910	910
query12	117	74	76	74
query13	1212	460	333	333
query14	5992	2193	2073	2073
query14_1	1963	1943	1936	1936
query15	177	123	110	110
query16	911	367	353	353
query17	791	455	374	374
query18	2336	333	241	241
query19	169	148	109	109
query20	72	70	70	70
query21	201	105	86	86
query22	5569	5345	5389	5345
query23	6660	6235	6073	6073
query23_1	6150	5986	6020	5986
query24	7276	1120	770	770
query24_1	762	801	781	781
query25	440	305	265	265
query26	1224	244	139	139
query27	2760	438	258	258
query28	4674	1497	1477	1477
query29	938	451	363	363
query30	241	155	132	132
query31	816	403	333	333
query32	133	77	77	77
query33	460	215	189	189
query34	977	880	482	482
query35	401	420	348	348
query36	586	560	541	541
query37	122	85	75	75
query38	999	851	833	833
query39	490	475	465	465
query39_1	454	452	464	452
query40	200	94	82	82
query41	59	59	56	56
query42	75	77	74	74
query43	233	236	210	210
query44	1018	548	575	548
query45	109	104	96	96
query46	791	876	510	510
query47	740	772	699	699
query48	303	317	235	235
query49	528	246	181	181
query50	792	259	190	190
query51	8047	7909	8043	7909
query52	71	67	57	57
query53	192	197	154	154
query54	218	179	155	155
query55	73	59	53	53
query56	187	177	174	174
query57	651	765	686	686
query58	199	160	174	160
query59	1193	1205	1080	1080
query60	252	181	171	171
query61	133	122	119	119
query62	347	205	177	177
query63	176	143	137	137
query64	2676	730	608	608
query65	1628	1579	1681	1579
query66	1866	266	208	208
query67	9842	9645	9711	9645
query68	3021	1227	757	757
query69	352	218	191	191
query70	675	625	618	618
query71	251	172	168	168
query72	2352	1732	1610	1610
query73	625	628	316	316
query74	1992	1230	1136	1136
query75	1182	1115	962	962
query76	2379	741	558	558
query77	257	271	221	221
query78	3811	3756	3247	3247
query79	2358	787	608	608
query80	1559	351	269	269
query81	483	157	131	131
query82	604	120	93	93
query83	276	209	187	187
query84	290	106	89	89
query85	787	367	295	295
query86	382	177	175	175
query87	1012	963	892	892
query88	2774	2101	2107	2101
query89	286	194	172	172
query90	1981	127	121	121
query91	133	121	102	102
query92	80	69	70	69
query93	1449	1057	674	674
query94	620	246	208	208
query95	531	326	233	233
query96	808	607	290	290
query97	1072	1039	1023	1023
query98	157	136	133	133
query99	413	350	307	307
Total cold run time: 177405 ms
Total hot run time: 82064 ms

@hello-stephen

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

query1	0.00	0.01	0.00
query2	0.08	0.04	0.04
query3	0.25	0.11	0.09
query4	1.60	0.10	0.10
query5	0.17	0.16	0.17
query6	1.25	0.68	0.69
query7	0.03	0.01	0.00
query8	0.04	0.03	0.02
query9	0.29	0.22	0.21
query10	0.36	0.35	0.34
query11	0.16	0.11	0.12
query12	0.15	0.12	0.12
query13	0.30	0.30	0.30
query14	0.44	0.45	0.44
query15	0.36	0.36	0.34
query16	0.20	0.23	0.24
query17	0.64	0.64	0.67
query18	0.15	0.17	0.18
query19	1.10	1.12	1.10
query20	0.01	0.01	0.01
query21	15.44	0.16	0.11
query22	5.07	0.05	0.05
query23	16.19	0.24	0.10
query24	3.01	0.30	0.25
query25	0.10	0.05	0.03
query26	0.82	0.18	0.13
query27	0.04	0.04	0.04
query28	3.62	0.57	0.28
query29	12.44	3.12	2.55
query30	0.25	0.12	0.12
query31	2.76	0.37	0.17
query32	3.54	0.33	0.23
query33	1.47	1.51	1.51
query34	15.35	2.16	1.74
query35	1.76	1.72	1.73
query36	0.46	0.30	0.29
query37	0.06	0.04	0.04
query38	0.05	0.03	0.03
query39	0.03	0.02	0.03
query40	0.11	0.08	0.07
query41	0.09	0.02	0.02
query42	0.03	0.03	0.02
query43	0.03	0.03	0.03
Total cold run time: 90.3 s
Total hot run time: 14.65 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 83.87% (26/31) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 93.55% (29/31) 🎉
Increment coverage report
Complete coverage report

@zyp-V

zyp-V commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

@morrySnow please approve again; resolved conflicts ;

@morrySnow
morrySnow merged commit 4a9956e into apache:master Aug 31, 2026
29 checks passed
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.

4 participants