Skip to content

fix(pd): populate memberSize in GET / endpoint response#3003

Open
caglareker wants to merge 3 commits intoapache:masterfrom
caglareker:fix/issue-3002-bug-get-endpoint-always-returns-membersi
Open

fix(pd): populate memberSize in GET / endpoint response#3003
caglareker wants to merge 3 commits intoapache:masterfrom
caglareker:fix/issue-3002-bug-get-endpoint-always-returns-membersi

Conversation

@caglareker
Copy link
Copy Markdown

@caglareker caglareker commented Apr 20, 2026

Purpose of the PR

Main Changes

The memberSize field in BriefStatistics was never being set, so GET / always returned 0. Added the missing assignment from RaftEngine.getInstance().getMembers().size(), same pattern as the other fields right next to it.

Verifying these changes

  • trivial change
  • already covered by existing tests
  • needs new tests

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working pd PD module labels Apr 20, 2026
Copy link
Copy Markdown
Contributor

@bitflicker64 bitflicker64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally with Docker dev cluster , memberSize now returns 1 (was 0). LGTM

@caglareker
Copy link
Copy Markdown
Author

Thanks for testing it out, glad it works.

- Use pdService.getMembers() for memberSize (consistent with cluster())
  instead of RaftEngine directly, as suggested in issue apache#3002 discussion
- Add dataState field to BriefStatistics: exposes worst partition health
  state across all graphs, the most useful missing operational indicator
- Align graphSize to count only user-facing graphs (endsWith("/g")),
  matching the semantics of cluster() to avoid silent count discrepancy
- Add testQueryIndexInfo() to both RestApiTest classes to assert state,
  leader, memberSize > 0, and storeSize > 0 — catches this class of bug
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Apr 20, 2026
@imbajin
Copy link
Copy Markdown
Member

imbajin commented Apr 20, 2026

Tested locally with Docker dev cluster , memberSize now returns 1 (was 0). LGTM

maybe we need test again for the new logic
4db9735

statistics.memberSize = membersResp.get().get(0).getMembersList().size();

statistics.storeSize = pdService.getStoreNodeService().getActiveStores().size();
statistics.graphSize = pdService.getPartitionService().getGraphs().size();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous fix adds:
statistics.memberSize = RaftEngine.getInstance().getMembers().size();

But the cluster() method (the "correct" counterpart) uses the service layer:

pdService.getMembers(Pdpb.GetMembersRequest.newBuilder().build(), response);
statistics.memberSize = pdList.size();  // from pdService, not RaftEngine

The issue discussion (comments 3–4 from bitflicker64 and dosubot) explicitly recommends using pdService.getMembers().size() for consistency with cluster() and to stay in the service layer. The merged fix goes against this recommendation.

@bitflicker64
Copy link
Copy Markdown
Contributor

Tested locally with Docker dev cluster , memberSize now returns 1 (was 0). LGTM

maybe we need test again for the new logic 4db9735

Re-tested locally against commit 4db9735 , all fields return correctly: memberSize: 1, storeSize: 1, dataState: PState_Normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working pd PD module size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

[Bug] GET / endpoint always returns memberSize:0 regardless of actual PD member count

3 participants