unknowntpo commented on code in PR #23895:
URL: https://github.com/apache/kafka/pull/23895#discussion_r4558927553
##########
server/src/test/java/org/apache/kafka/server/EligibleLeaderReplicasIntegrationTest.java:
##########
@@ -353,13 +355,48 @@ public void
testLastKnownLeaderShouldBeElectedIfEmptyElr() throws ExecutionExcep
}
}
+ @ClusterTest(types = {Type.KRAFT}, metadataVersion =
MetadataVersion.IBP_4_0_IV1)
+ public void testElrUsesReplicationFactorOfTargetPartition() throws
Exception {
+ try (var admin = clusterInstance.admin()) {
+ String testTopicName =
"testElrUsesReplicationFactorOfTargetPartition";
+ admin.updateFeatures(
+ Map.of(EligibleLeaderReplicasVersion.FEATURE_NAME,
+ new
FeatureUpdate(EligibleLeaderReplicasVersion.ELRV_1.featureLevel(),
FeatureUpdate.UpgradeType.UPGRADE))).all().get();
+ clusterInstance.createTopicWithAssignment(testTopicName, Map.of(
+ 0, List.of(4, 0, 1, 2),
+ 1, List.of(0, 1, 2, 3)));
+
+ // Decrease the replication factor of partition 0 only.
+ admin.alterPartitionReassignments(Map.of(new
TopicPartition(testTopicName, 0),
+ Optional.of(new
NewPartitionReassignment(List.of(4))))).all().get();
+ TestUtils.waitForCondition(() ->
admin.listPartitionReassignments().reassignments().get().isEmpty() &&
+ partition(admin, testTopicName, 0).replicas().size() == 1,
+ "Timed out waiting for the reassignment of partition 0");
+
+ ConfigResource configResource = new
ConfigResource(ConfigResource.Type.TOPIC, testTopicName);
+ admin.incrementalAlterConfigs(Map.of(configResource, List.of(new
AlterConfigOp(
+ new ConfigEntry(TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, "3"),
AlterConfigOp.OpType.SET)))).all().get();
Review Comment:
For partition 1 the order does not matter: its ELR is decided when broker 1
shuts down, after both steps. The test fails without the fix.
But your order hits another bug on partition 0. Completing the reassignment
to [4] used the old replica count, min(3, 4) = 3, so the removed brokers 0, 1
and 2 were put in the ELR. The latest commit fixes it and adds a unit test in
PartitionChangeBuilderTest. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]