wanwenli opened a new pull request #10686: URL: https://github.com/apache/kafka/pull/10686
### Summary `ReassignPartitionsCommand` does _not_ check whether the replication factor of a partition is the same as existing replication factor, which may result that different partitions of a topic have different number of replicas. A few years ago, I attempted a fix in `ReassignPartitionsCommand` within https://github.com/apache/kafka/pull/1779, but now I think it should be fixed on the broker side. ### Tests Firstly, the closest test class that is potentially able to cover this PR is `ReassignPartitionsIntegrationTest.scala`. However, it only has successful cases. Therefore, I simulated a reassignment that goes into the if branch in this PR and confirmed that this reassignment could not complete I also built a 3-node Kafka cluster on my laptop with Docker containers and used a few shell scripts to test. Create a topic ``` bin/kafka-topics.sh --bootstrap-server localhost:29092 --create --topic test-reassign-partitions --partitions 3 --replication-factor 3 ``` reassignment-plan.json ``` { "version":1, "partitions":[ { "topic": "test-reassign-partitions", "partition": 0, "replicas" :[1, 2] } ] } ``` Execute a partition reassignment ``` bin/kafka-reassign-partitions.sh --bootstrap-server localhost:29092 --reassignment-json-file reassignment-plan.json --execute ``` The output is ``` Current partition replica assignment {"version":1,"partitions":[{"topic":"test-reassign-partitions","partition":0,"replicas":[2,1,0],"log_dirs":["any","any","any"]}]} Save this to use as the --reassignment-json-file option during rollback Error reassigning partition(s): test-reassign-partitions-0: Replica assignment on test-reassign-partitions-0: [1, 2] violates its replication factor ``` -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org