fix(pd): pd raft-follower failed to get leader address due to npe#2919
fix(pd): pd raft-follower failed to get leader address due to npe#2919VGalaxies merged 1 commit intoapache:masterfrom
Conversation
| final InvokeContext invokeCtx = new InvokeContext(); | ||
| final InvokeCallback invokeCallback = new InvokeCallback() { |
There was a problem hiding this comment.
Any context for it? And we should add some basic tests to ensure the logic right
There was a problem hiding this comment.
The current implementation throws a NullPointerException (NPE) when performing cluster tests on a 3-node PD setup (see image).
Follower side:

Leader side (which has no any dbCompaction log):

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:

Leader side log which is expected:

There was a problem hiding this comment.
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
InvokeContextwith a new instance instead of usingnullin theinternalCallAsyncWithRpcmethod
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Purpose of the PR
Main Changes
Verifying these changes
Does this PR potentially affect the following parts?
Documentation Status
Doc - TODODoc - DoneDoc - No Need