Skip to content

fix(pd): pd raft-follower failed to get leader address due to npe#2919

Merged
VGalaxies merged 1 commit intoapache:masterfrom
JisoLya:fix-pd-redirect
Dec 17, 2025
Merged

fix(pd): pd raft-follower failed to get leader address due to npe#2919
VGalaxies merged 1 commit intoapache:masterfrom
JisoLya:fix-pd-redirect

Conversation

@JisoLya
Copy link
Contributor

@JisoLya JisoLya commented Dec 15, 2025

Purpose of the PR

  • close #xxx

Main Changes

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • xxx

Does this PR potentially affect the following parts?

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. pd PD module raft labels Dec 15, 2025
Comment on lines +63 to 64
final InvokeContext invokeCtx = new InvokeContext();
final InvokeCallback invokeCallback = new InvokeCallback() {
Copy link
Member

Choose a reason for hiding this comment

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

Any context for it? And we should add some basic tests to ensure the logic right

Copy link
Contributor Author

@JisoLya JisoLya Dec 15, 2025

Choose a reason for hiding this comment

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

The current implementation throws a NullPointerException (NPE) when performing cluster tests on a 3-node PD setup (see image).
Follower side:
image

Leader side (which has no any dbCompaction log):
image

The issue is reproducible with this test code:

@Test
    public void TestSimplePd() throws PDException {
		// 8686: leader, 8688 and 8687 are followers
        String addr = "127.0.0.1:8687";
        PDConfig pdConfig = PDConfig.of(addr);
        PDClient client = PDClient.create(pdConfig);
        client.dbCompaction();
    }

Send dbCompaction to followers after changes:
Follower side log:
image
Leader side log which is expected:
image

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 17, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a NullPointerException (NPE) in the PD raft-follower component that occurred when attempting to get the leader address. The root cause was passing a null InvokeContext to JRaft's invokeAsync() method, which expects a non-null context object.

Key Change:

  • Initialize InvokeContext with a new instance instead of using null in the internalCallAsyncWithRpc method

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

@github-project-automation github-project-automation bot moved this from In progress to In review in HugeGraph PD-Store Tasks Dec 17, 2025
@VGalaxies VGalaxies merged commit d28526e into apache:master Dec 17, 2025
19 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in HugeGraph PD-Store Tasks Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer pd PD module raft size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants