tikv / tikv/pd

`/regions/replicated` reports incorrect placement scheduling state

Open
#11,055 0 comments 0 reactions 0 assignees View on GitHub
severity/minor type/bug
Dominant language
Go
Stars
1.2k
Forks
783
Avg merge
4d 15h
Merged PRs (30d)
33

Description

## Bug Report

### What did you do?

Configure placement rules for a key range and query:

`GET /pd/api/v1/regions/replicated?startKey=...&endKey=...`

Exercise the following states:

- All placement rules are satisfied.
- A missing peer has a legal scheduling target.
- A legal target is temporarily unavailable.
- A missing, down, or offline peer has no legal target.
- A Region has pending peers or no leader.
- The requested key range has no Region metadata or contains an internal gap.

This is related to #5095, which previously addressed inaccurate results caused
by the waiting list, but the endpoint still cannot reliably represent placement
scheduling progress.

### What did you expect to see?

- `REPLICATED` only when RuleChecker has no remaining placement work.
- `INPROGRESS` when placement is incomplete but can still progress, is waiting
for temporary state recovery, or the requested range metadata is incomplete.
- `PENDING` only when the current topology has no legal placement action.

The status query should be side-effect free and should not require a full Store
scan for every completed Region.

### What did you see instead?

The endpoint combines placement fit results with state from the checker pending
list. The pending list represents historical or temporary filtering state, not
whether the current topology has a legal scheduling target.

As a result:

- Schedulable or temporarily blocked work can be reported as `PENDING`.
- Placement work with no legal target can remain `INPROGRESS`.
- An empty or discontinuous Region scan can be reported as complete.
- Reading the status can interact with placement-fit cache state.

### What version of PD are you using (`pd-server -V`)?

Current `master` at commit `070828c2b2032c499ff224c3f3730b5637fd3226`.

Contributor guide

Open the contributing guide

Research direction

Start at the GET /pd/api/v1/regions/replicated endpoint and trace how RuleChecker results, the checker pending list, placement-fit cache state, and Region metadata determine each status. Exercise the listed topology and key-range cases, then verify that status reads are side-effect free and avoid a full Store scan for completed Regions.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend, distributed-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.