Skip to content

fix(pd): bound member lookups in RaftEngine.getMembers() - #3409

Open
ShryukGrandhi wants to merge 1 commit into
apache:masterfrom
ShryukGrandhi:fix/issue-3172-bug-describe-the-main-problem
Open

ShryukGrandhi wants to merge 1 commit into
apache:masterfrom
ShryukGrandhi:fix/issue-3172-bug-describe-the-main-problem

Conversation

@ShryukGrandhi

Copy link
Copy Markdown

Purpose of the PR

On 1.7.0 every GetMemberRequest bolt call failed with a message-less NPE because RaftRpcClient passed a null InvokeContext. Master already passes new InvokeContext(), so that root cause is gone. Two related gaps from the issue are still on master:

  • RaftEngine.getMembers() calls future.get() with no timeout for each peer (and checks isCompletedExceptionally() before the get, which races with completion). One unresponsive peer can stall /v1/members. A null response was only handled by accident, through an NPE that got caught.
  • RaftRpcClient logs only t.getMessage() when the bolt call throws. That is how the 1.7.0 failure showed up as failed to call rpc to X. null with no stack trace.

Main Changes

  • getMembers() now waits up to config.getRpcTimeout() per peer, the same bound getLeaderGrpcAddress() got in fix(pd): add timeout and null-safety to getLeaderGrpcAddress() #2961. A timeout, an exception or a null response marks that peer Offline with its raft endpoint, and the remaining peers are still reported.
  • RaftRpcClient passes the exception to the logger, so the stack trace gets logged.

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:
    • Added RaftEngineLeaderAddressTest#testGetMembersMarksUnresponsivePeerOffline. One peer returns a future that never completes, another answers normally. Without the fix the test blocks in future.get() and hits its 10s timeout. With the fix the first peer is reported Offline and the leader Up with its gRPC URL.
    • mvn test -pl hugegraph-pd/hg-pd-test -am -Ppd-core-test: 202 tests run, 1 failure (RaftEngineReadIndexTest#testBackoffStartsOverAfterAnAnswerThatIsNotBusy, a timing assertion). It fails the same way on unmodified master on my machine and is unrelated to this change.

Does this PR potentially affect the following parts?

  • Dependencies
  • Modify configurations
  • The public API
  • Other affects (typed here)
  • Nope

Documentation Status

  • Doc - TODO: required documentation is pending; complete it before merging.
  • Doc - Done: documentation is included here or linked below.
  • Doc - No Need: no user-visible documentation is affected.

getMembers() waited on each peer's GetMemberRequest future without a
timeout, so an unresponsive peer could stall /v1/members. Use the same
rpc timeout as getLeaderGrpcAddress(), treat a null response as offline,
and log the full exception when the bolt call fails.

Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] describe the main problem

1 participant