Skip to content

KAFKA-13940; Return NOT_LEADER_OR_FOLLOWER if DescribeQuorum sent to non-leader#12517

Merged
hachikuji merged 2 commits intoapache:trunkfrom
hachikuji:KAFKA-13940
Aug 17, 2022
Merged

KAFKA-13940; Return NOT_LEADER_OR_FOLLOWER if DescribeQuorum sent to non-leader#12517
hachikuji merged 2 commits intoapache:trunkfrom
hachikuji:KAFKA-13940

Conversation

@hachikuji
Copy link
Copy Markdown
Contributor

@hachikuji hachikuji commented Aug 15, 2022

Currently the server will return INVALID_REQUEST if a DescribeQuorum request is sent to a node that is not the current leader. In addition to being inconsistent with all of the other leader APIs in the raft layer, this error is treated as fatal by both the forwarding manager and the admin client. Instead, we should return NOT_LEADER_OR_FOLLOWER as we do with the other APIs. This error is retriable and we can rely on the admin client to retry it after seeing this error.

Note that we could also check for this error in ForwardingManager and retry the request from that context, but the current forwarding logic is only setup to handle retries for requests sent to the controller, which is logically distinct from the raft leader. The DescribeQuorum is a bit of an oddball from an API perspective because it is a multi-partition request, but it is always forwarded to the controller since there is only one raft partition. So to handle this case specially, we would have to unwrap the envelope and check the error for the __cluster_metadata partition. It seemed simpler to rely on the admin client to retry.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

Copy link
Copy Markdown
Member

@dajac dajac left a comment

Choose a reason for hiding this comment

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

Thanks for the patch. Left a small comment for consideration.

@jsancio jsancio added core Kafka Broker 3.3 labels Aug 16, 2022
Copy link
Copy Markdown
Member

@dajac dajac left a comment

Choose a reason for hiding this comment

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

LGTM, assuming tests pass. Thanks!


if (!quorum.isLeader()) {
return DescribeQuorumRequest.getTopLevelErrorResponse(Errors.INVALID_REQUEST);
return DescribeQuorumResponse.singletonErrorResponse(
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.

We have documentation comments for handleFetchRequest and other handleXXXRequest methods, how about adding documentation comments for handleDescribeQuorumRequest.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, this part at least seems self-explanatory. Do you see something else that deserves more explanation? Would you mind submitting a follow-up PR if you do? I am happy to review.

@hachikuji hachikuji merged commit e5b865d into apache:trunk Aug 17, 2022
hachikuji added a commit that referenced this pull request Aug 17, 2022
…non-leader (#12517)

Currently the server will return `INVALID_REQUEST` if a `DescribeQuorum` request is sent to a node that is not the current leader. In addition to being inconsistent with all of the other leader APIs in the raft layer, this error is treated as fatal by both the forwarding manager and the admin client. Instead, we should return `NOT_LEADER_OR_FOLLOWER` as we do with the other APIs. This error is retriable and we can rely on the admin client to retry it after seeing this error.

Reviewers: David Jacot <djacot@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Kafka Broker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants