[Bug] PD task REST: balanceLeaders throws a bare HTTP 500 during the balance-shard window, and task responses cannot be told apart from a no-op or a follower answer
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 70/100
Research direction
The bug is in TaskAPI.java lines 92-95 where balanceLeaders throws PDException without a handler. Compare with sibling endpoints like patrolPartitions that catch and return toJSON(e). Also examine TaskScheduleService.java:478 for the error message. After fixing, test the REST endpoints /v1/task/balanceLeaders and /v1/task/patrolPartitions to ensure they return proper JSON instead of a bare 500.
Written by the indexing model from the issue text.
Description
Bug Type (问题类型)
rest-api (结果不合预期)
Before submit
- I have confirmed and searched that there are no similar problems in the historical issue and documents
Environment (环境信息)
- Server Version: master
83ef9f3(pd imagesha256:69dc1d4e8625) - Backend: HStore, 3 PD + 3 Store, 12 shard groups
- OS: kind v0.33 (Kubernetes 1.37.0)
Expected & Actual behavior (期望与实际表现)
Measured 2026-09-22 while executing the documented recovery sequence (patrolPartitions, balanceLeaders, balancePartitions) on the PD leader with a follower as control:
GET /v1/task/balanceLeaderswithin 180 s of abalancePartitionscall (which sets the balance-shard key even when it moves nothing) answers{"timestamp":...,"status":500,"error":"Internal Server Error","path":"/v1/task/balanceLeaders"}with no reason. The reason (PDException: balance shard is processing, please try later!, TaskScheduleService.java:478) appears only in the PD log. Cause:TaskAPI.balanceLeaders(TaskAPI.java:92-95) declaresthrows PDExceptionwith no handler, while its siblings catch and returntoJSON(e). One-line fix.GET /v1/task/patrolPartitionsreturns the byte-identical body{"status": 0,"partitions": [ ]}on the leader and on a follower, whether or not it repaired anything; a follower does no work and reports success.balancePartitionsdiffers by two bytes ({}from the leader, empty body from a follower). Operators driving recovery over REST cannot tell "ran and repaired", "ran, nothing to do" and "hit a follower, did nothing" apart without reading PD logs.
Ask: catch the PDException in balanceLeaders like the sibling endpoints; and have the task endpoints either redirect to the leader (as the read APIs do via getMembers) or answer an explicit error naming the leader, plus include what was done (groups reallocated, leaders moved, partitions moved) in the body.
- Dominant language
- Java
- Stars
- 3.2k
- Forks
- 637
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 22
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/hugegraph
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
apache/hugegraph#3142 · 7 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
apache/hugegraph#3238 · 2 comments ·
Maintainers usually reply within 1 day
All issues in apache/hugegraph
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
checkstyle/checkstyle#21755 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/copilot-sdk#2782 ·
Maintainers usually reply within 1 day
-
documentation Good for newcomer quick win
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
CodeForPhilly/benefit-decision-toolkit#519 ·
Maintainers usually reply within 1 day
-
area-deployment triage:bot-seen triage:needs-human
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/aspire#20533 · 1 comment ·
Maintainers usually reply within 1 day