Skip to content

HDDS-17448. gRPC OM client should retry a not-ready leader like the Hadoop RPC client - #11760

Merged
adoroszlai merged 3 commits into
apache:masterfrom
peterxcli:HDDS-17448
Oct 27, 2026
Merged

adoroszlai merged 3 commits into
apache:masterfrom
peterxcli:HDDS-17448

Conversation

@peterxcli

@peterxcli peterxcli commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

When the OM leader is not ready yet, for example right after a leader change, the Hadoop RPC client keeps retrying that OM with a growing wait. The gRPC client used by the S3 Gateway doesn't:

  • The OM retry policy only recognizes OMLeaderNotReadyException when it gets a ServiceException, but GrpcOmTransport#unwrapException hands it the OM exception itself. So the gRPC client treats a not-ready leader like any other failure and fails over to the next OM without waiting.
  • Only the leader path has a retry loop. When a follower read reaches a not-ready leader, it falls back to the leader path and sends another request right away.

With this change:

  • unwrapException returns a ServiceException with the RemoteException cause for errors from the OM, the same shape the Hadoop RPC client passes to the retry policy. This also drops the reflection that rebuilt the OM exception there.
  • The retry loop moves from submitRequestToLeader up to GrpcOmTransport#submitRequest, so it covers both follower read and the leader path, like RetryProxy does for the Hadoop RPC client.
  • The gRPC follower read throws OMLeaderNotReadyException to that loop instead of falling back to the leader, the same as HadoopRpcOMFollowerReadFailoverProxyProvider.

A follower read error that can't fail over, like RESOURCE_EXHAUSTED, now ends as an OMException, the same as on the leader path, instead of a raw StatusRuntimeException.

The client still reads the exception class and message from the status description. Replacing that with a structured error from the OM is HDDS-17462.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-17448

How was this patch tested?

New tests in TestS3GrpcOmTransport, with an OM leader that isn't ready for its first two requests:

  • a leader request is retried on the same OM until it succeeds, and the other OM never sees it;
  • a follower read is retried the same way, and every retry is still a follower read.

TestGrpcOMFollowerReadFailoverProxyProvider now expects OMLeaderNotReadyException to be thrown to the caller. All three tests fail without the fix.

Copilot AI balanced review requested due to automatic review settings October 25, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions github-actions Bot added the om label Oct 25, 2026

@chihsuan chihsuan left a comment

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.

Thanks for the follow-up on #11418! @peterxcli LGTM

@ivandika3 ivandika3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @peterxcli , LGTM +1. Left some minor comments.

Comment on lines 201 to 202
while (tryOtherHost) {
tryOtherHost = false;

@ivandika3 ivandika3 Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Let's take this opportunity to cleanup this tryOtherHost condition. It's currently not used. We can also rename it to shouldRetry.

Also the

        if (!tryOtherHost) {
          throw new OMException(resultCode);
        }

is not needed since outside the loop we already throw OMException.

Additionally, shouldRetry actually does a failover so shouldRetry might not be a good method name.

I'm OK if you defer this to a follow up ticket. The GrpcOmTransport is readability is pretty poor IMO so we might need to have a wider cleanup / refactor. To name a few

  • Separate the concern for exception handling by using some kind of gRPC StatusRuntimeException to Hadoop RemoteException adapter.
  • Rename host to currentHost (or leaderHost if it's supposed to be pointed to the leader).
  • Separate the gRPC channel building to a separate method
  • Do a compatibility test on the gRPC exception message so that it can be parsed by the client.

@Russole Russole left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @peterxcli for the PR. LGTM!

@adoroszlai
adoroszlai merged commit 47f646b into apache:master Oct 27, 2026
127 of 129 checks passed
@adoroszlai

Copy link
Copy Markdown
Contributor

Thanks @peterxcli for the patch, @chihsuan, @ivandika3, @Russole for the review.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants