You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "kevin-wu24 (via GitHub)" <gi...@apache.org> on 2025/07/09 20:14:04 UTC
[PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
kevin-wu24 opened a new pull request, #20136:
URL: https://github.com/apache/kafka/pull/20136
This PR adds a check to the storage tool's format command which throws a `TerseFailure` when both the following are true:
- The `controller.quorum.voters` config is defined
- The node is formatted with `--standalone` or `--initial-controllers`
If both of the above are true, it is possible to have two voter sets. For example, in a three node setup, the two nodes that formatted with `--no-initial-controllers` could form quorum with each other since they have the static voter set, and the `--standalone` node would ignore the config and read the voter set of itself from its log, forming its own quorum of 1.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "TaiJuWu (via GitHub)" <gi...@apache.org>.
TaiJuWu commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2214625224
##########
raft/src/main/java/org/apache/kafka/raft/QuorumConfig.java:
##########
@@ -57,6 +57,9 @@ public class QuorumConfig {
public static final String QUORUM_VOTERS_CONFIG = QUORUM_PREFIX + "voters";
public static final String QUORUM_VOTERS_DOC = "Map of id/endpoint information for " +
"the set of voters in a comma-separated list of <code>{id}@{host}:{port}</code> entries. " +
+ "This is the old way of defining membership for controller quorums and should NOT be " +
+ "set if using dynamic quorums. Instead, controller.quorum.bootstrap.servers should be set," +
+ "and the voter set is determined by the --standalone or --initial-controllers flags when formatting." +
Review Comment:
Sorry but I have a little confusing, maybe it because my poor English.
the statement `and the voter set is determined` is static voter set or dynamic voter set?
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "kevin-wu24 (via GitHub)" <gi...@apache.org>.
kevin-wu24 commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2198387770
##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -135,6 +135,15 @@ object StorageTool extends Logging {
featureNamesAndLevels(_).foreachEntry {
(k, v) => formatter.setFeatureLevel(k, v)
})
+ if (!config.quorumConfig.voters().isEmpty &&
Review Comment:
voters is a list, not an option, so there isn't a `isPresent` for me to call.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489; Extra validation when formatting a node [kafka]
Posted by "jsancio (via GitHub)" <gi...@apache.org>.
jsancio merged PR #20136:
URL: https://github.com/apache/kafka/pull/20136
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "ahuang98 (via GitHub)" <gi...@apache.org>.
ahuang98 commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2198758987
##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -387,22 +387,32 @@ Found problem:
}
@Test
- def testFormatWithStandaloneAndInitialControllersFailsWithVotersConfig(): Unit = {
+ def testFormatWithStandaloneFailsWithVotersConfig(): Unit = {
Review Comment:
`VotersConfig` -> `StaticVotersConfig`?
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "kevin-wu24 (via GitHub)" <gi...@apache.org>.
kevin-wu24 commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2200807511
##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -376,6 +376,8 @@ Found problem:
val availableDirs = Seq(TestUtils.tempDir())
val properties = new Properties()
properties.putAll(defaultStaticQuorumProperties)
+ properties.remove("controller.quorum.voters")
+ properties.put("controller.quorum.bootstrap.servers", "localhost:9093")
Review Comment:
Yeah I think I'll just define the properties from scratch.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "kevin-wu24 (via GitHub)" <gi...@apache.org>.
kevin-wu24 commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2200806228
##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -135,6 +135,15 @@ object StorageTool extends Logging {
featureNamesAndLevels(_).foreachEntry {
(k, v) => formatter.setFeatureLevel(k, v)
})
+ if (!config.quorumConfig.voters().isEmpty &&
+ (namespace.getString("initial_controllers") != null || namespace.getBoolean("standalone"))) {
Review Comment:
> or, thoughts on moving this check to be with the existing config validations under L155?
I put this before L155 because at that point we have already made calls to modify formatter state if one of `--standalone` or `--initial-controllers` is set. Basically I think it is cleaner to fail first if the set up is invalid.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "kevin-wu24 (via GitHub)" <gi...@apache.org>.
kevin-wu24 commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2198390326
##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -376,6 +376,8 @@ Found problem:
val availableDirs = Seq(TestUtils.tempDir())
val properties = new Properties()
properties.putAll(defaultStaticQuorumProperties)
+ properties.remove("controller.quorum.voters")
+ properties.put("controller.quorum.bootstrap.servers", "localhost:9093")
Review Comment:
Yeah I think I'll use `defaultDynamicQuorumProperties` and make the process.role a broker
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "jsancio (via GitHub)" <gi...@apache.org>.
jsancio commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2228776343
##########
docs/ops.html:
##########
@@ -4027,8 +4027,8 @@ <h5 class="anchor-heading"><a id="static_versus_dynamic_kraft_quorums" class="an
When using a static quorum, the configuration file for each broker and controller must specify
the IDs, hostnames, and ports of all controllers in <code>controller.quorum.voters</code>.<p>
- In contrast, when using a dynamic quorum, you should set
- <code>controller.quorum.bootstrap.servers</code> instead. This configuration key need not
+ In contrast, when using a dynamic quorum, <code>controller.quorum.bootstrap.servers</code>
+ is set instead and <code>controller.quorum.voters</code> must not be set. This configuration key need not
Review Comment:
Thanks for fixing the documentation. Do you mind swapping the order? Let's explain how to configure the node for dynamic voters and in the next paragraph explain how to configure for static voters.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "ahuang98 (via GitHub)" <gi...@apache.org>.
ahuang98 commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2198338634
##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -135,6 +135,15 @@ object StorageTool extends Logging {
featureNamesAndLevels(_).foreachEntry {
(k, v) => formatter.setFeatureLevel(k, v)
})
+ if (!config.quorumConfig.voters().isEmpty &&
Review Comment:
nit: why not use isPresent?
##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -135,6 +135,15 @@ object StorageTool extends Logging {
featureNamesAndLevels(_).foreachEntry {
(k, v) => formatter.setFeatureLevel(k, v)
})
+ if (!config.quorumConfig.voters().isEmpty &&
+ (namespace.getString("initial_controllers") != null || namespace.getBoolean("standalone"))) {
Review Comment:
store value of initial_controllers and standalone in vars given that you may need to reference them again later in the function?
##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -135,6 +135,15 @@ object StorageTool extends Logging {
featureNamesAndLevels(_).foreachEntry {
(k, v) => formatter.setFeatureLevel(k, v)
})
+ if (!config.quorumConfig.voters().isEmpty &&
+ (namespace.getString("initial_controllers") != null || namespace.getBoolean("standalone"))) {
Review Comment:
or, thoughts on moving this check to be with the existing config validations under L155?
##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -376,6 +376,8 @@ Found problem:
val availableDirs = Seq(TestUtils.tempDir())
val properties = new Properties()
properties.putAll(defaultStaticQuorumProperties)
+ properties.remove("controller.quorum.voters")
+ properties.put("controller.quorum.bootstrap.servers", "localhost:9093")
Review Comment:
hm, why do this instead of just using `defaultDynamicQuorumProperties`?
##########
docs/ops.html:
##########
@@ -4027,8 +4027,8 @@ <h5 class="anchor-heading"><a id="static_versus_dynamic_kraft_quorums" class="an
When using a static quorum, the configuration file for each broker and controller must specify
the IDs, hostnames, and ports of all controllers in <code>controller.quorum.voters</code>.<p>
- In contrast, when using a dynamic quorum, you should set
- <code>controller.quorum.bootstrap.servers</code> instead. This configuration key need not
+ In contrast, when using a dynamic quorum, <code>controller.quorum.bootstrap.servers</code>
+ is set instead and <code>controller.quorum.voters</code> must not be set. This configuration key need not
Review Comment:
btw, can you improve the config description as well? something like
[controller.quorum.voters](https://kafka.apache.org/documentation/#brokerconfigs_controller.quorum.voters)
Map of id/endpoint information for the set of static voters in a comma-separated list of {id}@{host}:{port} entries. This is the old way of defining membership for controller quorums and should NOT be set if using dynamic quorums. See [Static versus Dynamic KRaft Quorums](https://kafka.apache.org/documentation/#static_versus_dynamic_kraft_quorums) for details.
For example: 1@localhost:9092,2@localhost:9093,3@localhost:9094
##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -384,6 +386,48 @@ Found problem:
() => runFormatCommand(stream, properties, arguments.toSeq)).getMessage)
}
+ @Test
+ def testFormatWithStandaloneAndInitialControllersFailsWithVotersConfig(): Unit = {
Review Comment:
nit: break into two tests?
`testFormatWithStandaloneFailsWithStaticVotersConfig`
`testFormatWithInitialControllersFailsWithStaticVotersConfig`
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "kevin-wu24 (via GitHub)" <gi...@apache.org>.
kevin-wu24 commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2198390326
##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -376,6 +376,8 @@ Found problem:
val availableDirs = Seq(TestUtils.tempDir())
val properties = new Properties()
properties.putAll(defaultStaticQuorumProperties)
+ properties.remove("controller.quorum.voters")
+ properties.put("controller.quorum.bootstrap.servers", "localhost:9093")
Review Comment:
`defaultDynamicQuorumProperties` is for a controller. `defaultStaticQuorumProperties` is a broker.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "ahuang98 (via GitHub)" <gi...@apache.org>.
ahuang98 commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2198753693
##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -376,6 +376,8 @@ Found problem:
val availableDirs = Seq(TestUtils.tempDir())
val properties = new Properties()
properties.putAll(defaultStaticQuorumProperties)
+ properties.remove("controller.quorum.voters")
+ properties.put("controller.quorum.bootstrap.servers", "localhost:9093")
Review Comment:
any reason we can't create one version for the broker? or just define all the properties from scratch given there are only 4. feels funny that we are doing a put(staticProperties) then replacing the property that makes it static in the first place
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19489: storage tool should check controller.quorum.voters is not set alongside a dynamic quorum flag when formatting [kafka]
Posted by "kevin-wu24 (via GitHub)" <gi...@apache.org>.
kevin-wu24 commented on code in PR #20136:
URL: https://github.com/apache/kafka/pull/20136#discussion_r2217345250
##########
raft/src/main/java/org/apache/kafka/raft/QuorumConfig.java:
##########
@@ -57,6 +57,9 @@ public class QuorumConfig {
public static final String QUORUM_VOTERS_CONFIG = QUORUM_PREFIX + "voters";
public static final String QUORUM_VOTERS_DOC = "Map of id/endpoint information for " +
"the set of voters in a comma-separated list of <code>{id}@{host}:{port}</code> entries. " +
+ "This is the old way of defining membership for controller quorums and should NOT be " +
+ "set if using dynamic quorums. Instead, controller.quorum.bootstrap.servers should be set," +
+ "and the voter set is determined by the --standalone or --initial-controllers flags when formatting." +
Review Comment:
It's the dynamic voter set, since we format with `--standalone/--initial-controllers`.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org