DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
Discussion thread: here
JIRA: here [Change the link from KAFKA-1 to your own ticket]
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
...
Today, kafka-reassign-partitions.sh --execute submits all partition reassignments from the JSON in oneAdminClient#alterPartitionReassignments call (unless the user manually splits work). For large clusters this can create large bursts of replication traffic and controller work.
This KIP proposes tool-only pacing controls:
- --reassignment-batch-size — caps how many topic partitions are submitted per step (semantics differ slightly depending on mode; see below). 0 preserves legacy behavior (single request for the entire plan).
- --incremental — optional mode used with--reassignment-batch-size > 0 to keep at most Npartition reassignments in flight for this execution, submitting the next partition from a deterministic queue when a slot frees up.
- --reassignment-poll-interval-ms — how long the tool sleeps between polls while waiting for batch completion (non-incremental, between batches) and while driving incremental submissions; default 500 ms.
Ordering for both modes is (topic name, partition index), not the order of entries in the JSON file.
No broker protocol, controller, or metadata changes are required; pacing is implemented entirely in the reassignment tool using existing Admin APIs (alterPartitionReassignments, listPartitionReassignments, metadata reads).
...
- Operational risk: Submitting hundreds or thousands of partition reassignments in one RPC can stress replication links, disk, and the controller in ways that are hard to predict during maintenance windows.
- Limited operator control: Throttling (--throttle) limits bandwidth but does not limit how many partitions are simultaneously moving; operators often want serialised waves or bounded concurrency without hand-splitting JSON files.
- Manual workarounds: Teams split reassignment JSON by hand or wrap the tool in scripts that call alterPartitionReassignments in chunks — error-prone and inconsistent across deployments.
...
CLI (kafka-reassign-partitions.sh)
Option | Applies to | Semantics |
--reassignment-batch-size <int> | --execute only |
|
--incremental | --execute only | Requires --reassignment-batch-size > 0. Mutually exclusive interpretation of batch size as in-flight cap (see above). |
--reassignment-poll-interval-ms <long> | --execute only | Milliseconds to sleep between progress polls when the tool is waiting on reassignment state. Default 500. |
Validation and compatibility
- --reassignment-batch-size must be ≥ 0. Negative values are rejected.
- --incremental without --reassignment-batch-size > 0 is rejected at argument validation time.
- --reassignment-batch-size, --incremental and --incrementalreassignment-poll-interval-ms are not permitted with --list, --generate, --verify, or --cancel (same pattern as other execute-only options).
- --reassignment-poll-interval-ms must be > 0. Negative values are rejected.
Programmatic API
ReassignPartitionsCommand.executeAssignment gains parameters:
- int reassignmentBatchSize
- boolean incremental
- long reassignmentPollIntervalMs
Existing callers that omit pacing pass 0 and false to preserve legacy behaviour.
...
- Sort partitions deterministically (compareTopicPartitions).
- Maintain a pending deque and an in-flight map (submissions for this execute only).
- Loop until pending is empty: remove completed partitions from in-flight (using the same completion predicate as non-incremental wait paths), then submit new partitions up to the N in-flight cap.
- Poll interval between iterations when work remains: INCREMENTAL_REASSIGNMENT_POLL_INTERVAL_MS (500 ms in the default implementation).
...
Non-incremental wait between batches
- Poll interval: BATCH_REASSIGNMENT_POLL_INTERVAL_MSreassignmentPollIntervalMs (500 ms in the reference implementation).
- Completion uses existing findPartitionReassignmentStates / PartitionReassignmentState logic; inconsistent terminal states produce TerseException (same class of errors as today’s verify path).
...
- Default CLI: unchanged legacy path (reassignment-batch-size defaults to 0; incremental absent).
- Brokers / ZK / KRaft: no change.
- Wire protocol: unchanged (same Admin APIs).
...
- No timeout on batch-completion waits in the reference implementation; stuck reassignments can poll indefinitely until operator intervention (same class of risk as long-running admin operations without deadlines).
- Incremental + --additional: total cluster in-flight work can exceed N when multiple tool processes run overlapping plans; documentation / optional warnings are recommended.
Rejected alternatives
- Only documentation: “Split your JSON manually” — does not scale and yields inconsistent operations.
- New broker-side “max concurrent reassignments” quota: much larger scope; tool-side pacing addresses the common case without protocol work.
- Order = JSON file order only: rejected in favour of deterministic sorted order so behaviour is reproducible and independent of file editing.
Test plan
- Unit tests: batch splitting; incremental ordering; failure on second batch; completion predicate shared between wait and incremental removal.
- Args tests: invalid combinations; execute-only restriction for new flags.
- Integration / cluster tests: execute with small batch sizes (including batch size 1) in KRaft and ZK modes where the project already runs ClusterTest.
- Manual: large plan with --reassignment-batch-size and --list / --verify to observe waves and completion.
Documentation
- Extend the kafka-reassign-partitions section of the Kafka documentation / ops guides: semantics of 0, non-incremental batching, incremental, --additional, and verification with --verify.