Skip to content

[fix](feut) fix MetaServiceProxyTest - #66219

Open
mymeiyi wants to merge 1 commit into
apache:masterfrom
mymeiyi:fix-feut
Open

[fix](feut) fix MetaServiceProxyTest#66219
mymeiyi wants to merge 1 commit into
apache:masterfrom
mymeiyi:fix-feut

Conversation

@mymeiyi

@mymeiyi mymeiyi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 29, 2026 06:56
@mymeiyi
mymeiyi requested a review from gavinchou as a code owner July 29, 2026 06:56
@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?

@mymeiyi

mymeiyi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

/review

Copilot AI 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.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Fixes MetaServiceProxyTest flakiness by making the rate-limit exhaustion deterministic and updating the RPC invocation expectation accordingly.

Changes:

  • Adjusts rate-limit configuration to use a longer refresh window.
  • Consumes the entire quota via a single weighted getVisibleVersionAsync call.
  • Updates Mockito verification to expect one RPC call (the quota-consuming call) instead of none.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread fe/fe-core/src/test/java/org/apache/doris/cloud/rpc/MetaServiceProxyTest.java Outdated
Comment thread fe/fe-core/src/test/java/org/apache/doris/cloud/rpc/MetaServiceProxyTest.java Outdated
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66219

Problem Summary: MetaServiceProxyTest exhausted rate-limit permits through repeated calls with a one-second refresh period, so scheduler delays could replenish permits and make the assertion flaky. Consume the configured limit for a longer burst window with one weighted request, derive that weight explicitly from the QPS and burst settings, and return immediately completed mocked futures so async callbacks do not remain pending.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - `./run-fe-ut.sh --run org.apache.doris.cloud.rpc.MetaServiceProxyTest` (11 tests passed on the development machine)
    - FE Checkstyle passed with 0 violations
- Behavior changed: No
- Does this need documentation: No
@mymeiyi

mymeiyi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

/review

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

fe/fe-core/src/test/java/org/apache/doris/cloud/rpc/MetaServiceProxyTest.java:324

  • limitForPeriod scales with CPU_CORES and a hardcoded 60s burst window, which can make this unit test generate very large requests on high-core CI agents (and potentially slow down / increase memory usage). Consider capping the computed weight to a small upper bound for tests (e.g., min(computed, 100)), and/or using a smaller rateLimitBurstSeconds while keeping the test deterministic. Also, computing this with int risks overflow on unusually large environments—prefer long for the multiplication and only cast down if needed.
        int qpsPerCore = 1;
        int rateLimitBurstSeconds = 60;
        int limitForPeriod = qpsPerCore * CPU_CORES * rateLimitBurstSeconds;
        enableRateLimit(qpsPerCore, "", rateLimitBurstSeconds, 0);

fe/fe-core/src/test/java/org/apache/doris/cloud/rpc/MetaServiceProxyTest.java:320

  • This comment indicates the test is working around timing/scheduler behavior by using a long burst window, which can keep the test brittle and harder to reason about. A more maintainable approach is to make the rate-limit refill/refresh deterministic in tests (e.g., inject a controllable clock/ticker or explicitly disable/avoid background refresh) so assertions don’t depend on scheduler progress.
        // Consume limitForPeriod = qpsPerCore * CPU_CORES * burstSeconds in one weighted request.
        // A long burst window also prevents a refresh before the assertion if the scheduler stalls.

@mymeiyi

mymeiyi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Review context preparation failed before Codex ran; inspect the 'Prepare authoritative PR context and required AGENTS guides' step.
Workflow run: https://github.com/apache/doris/actions/runs/30430054963

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

@mymeiyi

mymeiyi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

/review

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17696	4010	4016	4010
q2	2003	314	199	199
q3	10281	1360	801	801
q4	4686	471	335	335
q5	7568	856	564	564
q6	209	171	135	135
q7	764	806	614	614
q8	10040	1574	1510	1510
q9	6139	4342	4273	4273
q10	6828	1713	1470	1470
q11	501	342	317	317
q12	770	571	455	455
q13	18106	3243	2693	2693
q14	269	261	238	238
q15	q16	772	781	706	706
q17	936	946	937	937
q18	7028	5918	5606	5606
q19	1387	1311	1042	1042
q20	792	665	566	566
q21	5813	2607	2505	2505
q22	429	360	299	299
Total cold run time: 103017 ms
Total hot run time: 29275 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4381	4382	4302	4302
q2	296	308	211	211
q3	4508	4912	4453	4453
q4	2057	2176	1367	1367
q5	4346	4265	4266	4265
q6	231	179	131	131
q7	1713	2003	1655	1655
q8	2429	2214	2075	2075
q9	7816	7775	7799	7775
q10	4713	4610	4185	4185
q11	578	407	380	380
q12	745	749	539	539
q13	3397	3568	2885	2885
q14	306	333	292	292
q15	q16	707	773	668	668
q17	1314	1323	1323	1323
q18	8227	7333	6907	6907
q19	1135	1062	1102	1062
q20	2194	2230	1949	1949
q21	5205	4521	4394	4394
q22	513	467	391	391
Total cold run time: 56811 ms
Total hot run time: 51209 ms

@hello-stephen

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

query5	4319	613	486	486
query6	459	223	216	216
query7	4851	621	343	343
query8	344	187	170	170
query9	8781	4040	4014	4014
query10	524	351	294	294
query11	5896	2330	2161	2161
query12	156	106	101	101
query13	1269	640	444	444
query14	6262	5159	4883	4883
query14_1	4258	4236	4234	4234
query15	213	204	180	180
query16	1004	488	444	444
query17	953	711	577	577
query18	2441	486	350	350
query19	220	190	156	156
query20	116	109	105	105
query21	234	153	141	141
query22	13519	13494	13363	13363
query23	17236	16420	16144	16144
query23_1	16271	16278	16251	16251
query24	7535	1739	1267	1267
query24_1	1313	1274	1336	1274
query25	581	457	389	389
query26	1344	363	218	218
query27	2595	607	373	373
query28	4987	2016	2037	2016
query29	1100	623	503	503
query30	353	261	228	228
query31	1129	1093	982	982
query32	108	73	62	62
query33	543	326	253	253
query34	1216	1102	642	642
query35	774	800	668	668
query36	1054	1049	902	902
query37	157	107	89	89
query38	1863	1760	1673	1673
query39	899	878	847	847
query39_1	838	874	855	855
query40	247	168	138	138
query41	67	62	62	62
query42	93	91	91	91
query43	323	320	283	283
query44	1408	769	742	742
query45	192	184	176	176
query46	1094	1196	689	689
query47	2165	2155	2058	2058
query48	412	388	294	294
query49	587	416	315	315
query50	1174	407	351	351
query51	10719	10411	10586	10411
query52	86	87	74	74
query53	266	269	201	201
query54	272	225	215	215
query55	76	72	66	66
query56	311	282	277	277
query57	1339	1300	1233	1233
query58	291	248	251	248
query59	1557	1653	1425	1425
query60	311	285	258	258
query61	158	159	145	145
query62	542	498	419	419
query63	237	202	204	202
query64	2806	1006	849	849
query65	4738	4643	4631	4631
query66	1798	489	382	382
query67	28606	28527	28449	28449
query68	3120	1583	969	969
query69	405	293	264	264
query70	897	792	819	792
query71	383	336	328	328
query72	2993	2622	2481	2481
query73	841	797	430	430
query74	5058	4932	4710	4710
query75	2516	2515	2137	2137
query76	2331	1157	766	766
query77	343	377	278	278
query78	11818	11899	11413	11413
query79	1469	1187	746	746
query80	1290	537	460	460
query81	560	332	291	291
query82	601	154	125	125
query83	376	324	293	293
query84	329	167	129	129
query85	965	609	517	517
query86	409	244	231	231
query87	1823	1814	1769	1769
query88	3693	2774	2746	2746
query89	431	378	336	336
query90	1907	195	204	195
query91	202	192	162	162
query92	63	58	53	53
query93	1700	1603	962	962
query94	722	343	319	319
query95	764	580	486	486
query96	1107	783	373	373
query97	2617	2653	2528	2528
query98	216	210	203	203
query99	1108	1108	976	976
Total cold run time: 263073 ms
Total hot run time: 176528 ms

@hello-stephen

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

query1	0.01	0.01	0.00
query2	0.09	0.04	0.05
query3	0.26	0.14	0.14
query4	1.61	0.14	0.14
query5	0.24	0.22	0.22
query6	1.29	1.06	1.01
query7	0.04	0.01	0.01
query8	0.05	0.04	0.03
query9	0.39	0.31	0.30
query10	0.56	0.58	0.55
query11	0.20	0.14	0.13
query12	0.18	0.14	0.14
query13	0.47	0.46	0.49
query14	1.02	1.04	1.00
query15	0.64	0.58	0.58
query16	0.31	0.33	0.32
query17	1.07	1.10	1.10
query18	0.22	0.21	0.21
query19	2.08	1.97	1.90
query20	0.01	0.02	0.01
query21	15.43	0.21	0.12
query22	4.90	0.05	0.05
query23	16.15	0.31	0.13
query24	2.97	0.42	0.34
query25	0.10	0.06	0.04
query26	0.75	0.20	0.15
query27	0.03	0.03	0.05
query28	3.62	0.95	0.56
query29	12.48	4.17	3.28
query30	0.28	0.15	0.15
query31	2.78	0.60	0.31
query32	3.23	0.60	0.48
query33	3.19	3.15	3.28
query34	15.71	4.19	3.54
query35	3.51	3.53	3.52
query36	0.56	0.42	0.44
query37	0.09	0.07	0.07
query38	0.04	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.16	0.16
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.04	0.04
Total cold run time: 96.96 s
Total hot run time: 24.96 s

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

Review opinion: approve. I found no blocking or new non-duplicate issues at head 25e20bd4b91ea5f92b6d35d7e8b4290ea8cc544d.

Critical checkpoints:

  • Goal and proof: the revised partition-version test derives the weighted request from the same qpsPerCore * CPU_CORES * burstSeconds formula as the production limiter, consumes the full period in one request, and verifies that the next request is rejected before a second RPC. The table-version path retains equivalent weighted-permit coverage.
  • Scope and clarity: this is a focused test-only patch. It changes only the two affected async rate-limit tests and adds the completed-future import.
  • Concurrency and lifecycle: no new threads or locks are introduced. Futures.immediateFuture runs the existing direct-executor success callback without leaving pending callback state or entering the client-shutdown path; the separate controlled failure test still covers delayed failure and shutdown. Static config and limiter state are restored/reset by the fixture, and FE tests use non-reused forks for singleton isolation.
  • Conditions and error handling: the rate-limit exception remains asserted, the Mockito count proves the rejected call does not reach the client, and no status/exception is silently discarded.
  • Configuration, compatibility, persistence, data writes, FE-BE propagation, and observability: no production behavior or configuration is changed, so these checkpoints are not applicable.
  • Performance and resources: the test builds one request proportional to 60 * availableProcessors() and performs one mocked RPC; this is bounded test-only work and does not affect a production hot path.
  • Tests and results: the patch updates targeted JUnit coverage; no regression .out files are involved. The PR reports 11 MetaServiceProxyTest tests and Checkstyle passing. I did not run builds or tests in this review-only runner.
  • Existing review context: the current head addresses the earlier naming, capacity derivation, and never-completed-future concerns. The remaining theoretical refresh-window/high-core observations are already represented in the existing review context and do not support a distinct inline finding.
  • User focus: no additional review focus was provided; the whole PR was reviewed.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

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

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Codex completed, but no new pull request review was submitted for the current head SHA.
Workflow run: https://github.com/apache/doris/actions/runs/30445822956

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

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.

3 participants