...
We can leverage the describe topics command in TopicCommand to add an option "--under-minisrmin-isr-partitions" to list out exactly which topic partitions are below "min.insync.replicas" and need fixing to maintain availability.
Public Interfaces
This change would add an additional flag "--under-min-minisrisr-partitions" to TopicCommand, but the output will follow the same format as the "under-replicated-partitions" and "offline-partitions" options.
Code Block |
---|
val reportUnderMinIsrPartitionsOpt = parser.accepts("under-min-isr-partitions",
"if set when describing topics, only show partitions which are under the configured minimum in-sync replica count") |
Proposed Changes
The challenge with supporting this additional feature is that the "min.insync.replicas" configuration may be set at a broker or topic level.
...
We can pre-fetch the "computed" topic configurations if "--under-min-minisrisr-partitions" option is specified to avoid making a separate AdminClient call per topic.
Code Block |
---|
# Assuming we have an AdminClient instance val adminClient = ... // Pre-fetch and get "computed" topic configs for all specified topics val computedTopicConfigs = if (reportUnderMinISRPartitionsreportUnderMinIsrPartitions) Option(adminClient.describeConfigs( topics.map(topic => new ConfigResource(ConfigResource.Type.TOPIC, topic)).asJavaCollection).all().get()) else None for (topic <- topics) ... if (describePartitions) { // Get "computed" topic "min.insync.replicas" for this topic val computedTopicMinISR = if (reportUnderMinISRPartitions) Option(computedTopicConfigs.get.get(new ConfigResource(ConfigResource.Type.TOPIC, topic)) .get(TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG).value().toInt) else None for ((partitionId, assignedReplicas) <- sortedPartitions) { ... // Print current topic partition if reportUnderMinISRPartitions and ISR count < "computed" min ISR if (... || (reportUnderMinISRPartitions && inSyncReplicas.size < computedTopicMinISR.get) { ... |
This means we need an additional flag "--bootstrap-server" to use AdminClient. KIP-377: TopicCommand to use AdminClient is already proposing a change to use AdminClient and introduce a "--bootstrap-server" option, so we can wait on leverage the changes in KIP-377 to be completed first before merging for this KIP's code.
Compatibility, Deprecation, and Migration Plan
...