Skip to content
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

KAFKA-14121: AlterPartitionReassignments API should allow callers to specify the option of preserving the replication factor #18983

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

brandboat
Copy link
Member

KAFKA-14121

Add new option allowReplicationFactorChange to alterPartitionReassignments. Set this option to false prevents partition replication factor being changed during partition reassignment.
See https://cwiki.apache.org/confluence/display/KAFKA/KIP-860%3A+Add+client-provided+option+to+guard+against+replication+factor+change+during+partition+reassignments for more detail

Committer Checklist (excluded from commit message)

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

…specify the option of preserving the replication factor
Copy link
Contributor

@clolov clolov 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 contributions! I have made an initial pass with some comment 😊

*/
public boolean allowReplicationFactorChange(boolean allow) {
this.allowReplicationFactorChange = allow;
return allowReplicationFactorChange;
Copy link
Contributor

Choose a reason for hiding this comment

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

On a quick cross-check with other *Options it appears that for such methods we return the *Options class itself. In other words, something along these lines

public AlterPartitionReassignmentsOptions allowReplicationFactorChange(boolean allow) {
    this.allowReplicationFactorChange = allow;
    return this;
}

@@ -2406,6 +2414,31 @@ private void updatePartitionInfo(
newPartInfo.elr);
}

private void validatePartitionReplicationFactorUnchanged(
PartitionRegistration part,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Could you align the first argument with the opening bracket as other methods in this file?

@@ -432,6 +433,21 @@ topicPartition, new PartitionReassignmentState(asList(0, 1, 2), asList(0, 1, 2),
}
}

@ClusterTest
public void testDisallowReplicationFactorChange() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add a test (or build on this one) which showcases that increasing the replication factor also fails?

setTopics(singletonList(new OngoingTopicReassignment().
setName("foo").setPartitions(singletonList(
new OngoingPartitionReassignment().setPartitionIndex(0).
setRemovingReplicas(singletonList(3)).
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Partition 0 started with replicas (0, 1, 2). For the sake of continuity, could you remove 0 and add 3 rather than the other way around?

setTopics(singletonList(new OngoingTopicReassignment().
setName("foo").setPartitions(singletonList(
new OngoingPartitionReassignment().setPartitionIndex(0).
setRemovingReplicas(singletonList(3)).
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Same comment as in the previous test

@@ -1922,6 +1922,135 @@ public void testReassignPartitions(short version) {
assertEquals(NONE_REASSIGNING, replication.listPartitionReassignments(null, Long.MAX_VALUE));
}

@ParameterizedTest
@ApiKeyVersionsSource(apiKey = ApiKeys.ALTER_PARTITION)
public void testAlterPartitionDisallowReplicationFactorChange(short version) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe there already are such tests, in which case please point them out to me, but if not, could you add the same tests but with setAllowReplicationFactorChange(true)?

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