This page is meant as a template for writing a KIP. To create a KIP choose Tools->Copy on this page and modify with your content and replace the heading with the next KIP number and a description of your issue. Replace anything in italics with your own description.
Current state: Under Discussion
Discussion thread: https://lists.apache.org/thread/vnzmqvcbfxo7hhyj9gzpgmdq59w3n7dy
JIRA: here
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
The reason for this KIP is to remove the requirement of brokers needed to run the storage tool before starting Kafka. When running kafka-storage format , nodes are required to supply a --cluster-id argument, which represents the cluster ID to which the node belongs, and this is persisted to the node's meta.properties file. Below are the other data that each node persists to disk upon invoking kafka-storage format :
For brokers, meta.properties ’ other data: node.id and directory id , are obtained from the node’s static config and randomly generated, respectively. Persisting this data does not need to be done before starting kafka.
For controllers, meta.properties ’ directory id may come from —-initial-controllers , but otherwise controllers are the same as brokers with respect to the above data.
The main purpose of cluster id is to prevent nodes from contacting other Kafka clusters (ref KIP-78). This KIP seeks to preserve this behavior around cluster id, while removing the necessity of formatting brokers and observer controllers.
Currently, Kafka relies on the operator/caller of kafka-storage format on all intended nodes in a cluster to generate consensus on the actual value of clusterID during format time. Additionally, KRaft guarantees that upon forming a given quorum X, X's members will all have the same cluster id contained in meta.properties, and that RPCs will only be handled by the leader if the request's cluster ID (if present) matches the leader's.
We still maintain that controllers who are part of the bootstrapped voter set must format, but observer controllers do not need to format, just like brokers. This can be enforced by requiring —-cluster-id when any of the KIP-853 format flags are provided or when the local node is part of its static voter set.
Cluster id was a znode, /cluster/id , that was initially empty. During the startup of a cluster, brokers would race to write a random UUID in ZK to this znode, which would never change after being set, via getOrGenerateClusterId() .
meta.properties
Introduce meta.properties v2 with optional cluster id (same as v0).
ClusterIdRecord + MetadataVersion
Introduce a new metadata record to store cluster id and a new MetadataVersion that supports encoding/decoding this record. This means that during formatting, the bootstrap ClusterIdRecord is only written if the cluster is formatted with a MV that supports this feature.
Storage Tool
--cluster-id is now optional for brokers + observer controllers. This flag is still required for "bootstrapping" controllers (i.e. controllers who are part of an initial dynamic voter set (determined by the --standalone or --initial-controllers) flags, or who are part of a static voter set).
Option 1: Continue to persist cluster id in meta.properties but have KRaft discover it + persist it
meta.properties is its source of truth, if this file is deleted or is changed, it means the broker/observer controller can join another cluster.
Option 2: Introduce a metadata record for cluster id
meta.properties, and update the raft client in-memory.meta.properties . The value in the metadata partition takes precedence.meta.properties , write it to meta.properties .meta.properties , this approach is no better than Option 1 unless the local node can use the cluster id value in its local metadata partition BEFORE contacting the leader and learning of the HWM. This means a node needs to read its local metadata log BEFORE discovering the HWM from the leader during startup to retrieve the cluster id.This section depends on which approach is chosen for the proposed changes.
WIP