Skip to content

KAFKA-19400: Update AddRaftVoterRequest RPC to version 1 #19982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

kevin-wu24
Copy link
Contributor

Add the ackWhenCommitted boolean field to the AddRaftVoterRequest RPC, and bump the RPC's version to 1.

  • The default value of ackWhenCommitted is true, and in this case the leader will return a response after committing the VotersRecord generated by the RPC.
  • If ackWhenCommitted == false, the leader will return a response after writing the VotersRecord to its own local log.
  • Add unit tests in KafkaRaftClientReconfigTest


// This method sets up the context so a test can send an AddVoter request after
// exiting this method
private void prepareToSendAddVoter(
Copy link
Contributor

@ahuang98 ahuang98 Jun 17, 2025

Choose a reason for hiding this comment

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

this name is a bit deceiving, this is all prep we do on the local (leader) node in order for it to be able to respond favorably to an addvoter request, could we perhaps rename to "prepareLeaderToReceiveAddVoter"?

I'm also not sure how I feel about having a helper method for this, I do see how this is quite a bit of code duplication but I wonder if it might be more clear to have this written out explicitly in the tests (you probably don't need to keep all the same assertions for all the tests)

Copy link
Contributor Author

@kevin-wu24 kevin-wu24 Jun 18, 2025

Choose a reason for hiding this comment

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

could we perhaps rename to "prepareLeaderToReceiveAddVoter"

Yeah, this is more accurate.

I wonder if it might be more clear to have this written out explicitly in the tests

I would prefer to have this code in a helper method, which applies to the other comment too. In my opinion, it's clearer to me when all of these tests do have the exact same assertions so long as they apply, because it means our new AckWhenCommitted field (or any other feature) is not unintentionally changing behavior elsewhere. For example, the metric values check prevented me from writing an incorrect implementation!

Another way to think about it is that in these AddVoter unit tests, we're testing the same state of KRaft essentially (i.e. how the local leader handles AddVoter RPC), but each test is changing one thing, which is the ackWhenCommitted value (true, false, or NOT_SUPPORTED). Because we want coverage, I think duplication is a natural side-effect.

Maybe I can just document the helpers/rename them as specific to these AddVoter tests?

ReplicaKey follower,
ReplicaKey newVoter,
int epoch
) throws Exception {
// The new voter is now a voter after writing the VotersRecord to the log
assertTrue(context.client.quorum().isVoter(newVoter));
checkLeaderMetricValues(3, 0, 1, context);
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't seem very extensible - maybe the above checks belong outside of this method

"KIP_853_PROTOCOL",
"KIP_996_PROTOCOL"
})
void testAddVoterCompatibility(RaftProtocol protocol) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

testAddVoterAckWhenCommittedUnsupported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also need to add KIP_1166 here too.

@github-actions github-actions bot removed the triage PRs from the community label Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants