Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/server/DynamicBrokerConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ class DynamicLogConfig(logManager: LogManager, server: KafkaServer) extends Brok
props ++= newBrokerDefaults
props ++= log.config.originals.asScala.filterKeys(log.config.overriddenConfigs.contains)

val logConfig = LogConfig(props.asJava)
val logConfig = LogConfig(props.asJava, log.config.overriddenConfigs)
log.updateConfig(logConfig)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,43 @@ class DynamicBrokerReconfigurationTest extends ZooKeeperTestHarness with SaslSet
stopAndVerifyProduceConsume(producerThread, consumerThread)
}

@Test
def testRetainTopicOverriddenConfigAfterConsecutiveConfigChange(): Unit = {
val topic2 = "testtopic2"
val topicProps = new Properties
topicProps.put(KafkaConfig.MinInSyncReplicasProp, "2")
TestUtils.createTopic(zkClient, topic2, 1, replicationFactor = numServers, servers, topicProps)
var log = servers.head.logManager.getLog(new TopicPartition(topic2, 0)).getOrElse(throw new IllegalStateException("Log not found"))
assertEquals(log.config.overriddenConfigs.size, 1)

val props = new Properties
props.put(KafkaConfig.LogMessageTimestampTypeProp, TimestampType.LOG_APPEND_TIME.toString)
reconfigureServers(props, perBrokerConfig = false, (KafkaConfig.LogMessageTimestampTypeProp, TimestampType.LOG_APPEND_TIME.toString))
// Verify that all broker defaults have been updated
servers.foreach { server =>
props.asScala.foreach { case (k, v) =>
assertEquals(s"Not reconfigured $k", server.config.originals.get(k).toString, v)
}
}

log = servers.head.logManager.getLog(new TopicPartition(topic2, 0)).getOrElse(throw new IllegalStateException("Log not found"))
assertEquals(log.config.overriddenConfigs.size, 1) // Verify topic-level config survives

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be good to check the actual config value


// Make a second broker-default change
props.clear()
props.put(KafkaConfig.LogRetentionTimeMillisProp, "604800000")
reconfigureServers(props, perBrokerConfig = false, (KafkaConfig.LogRetentionTimeMillisProp, "604800000"))
// Verify that all broker defaults have been updated again
servers.foreach { server =>
props.asScala.foreach { case (k, v) =>
assertEquals(s"Not reconfigured $k", server.config.originals.get(k).toString, v)
}
}

log = servers.head.logManager.getLog(new TopicPartition(topic2, 0)).getOrElse(throw new IllegalStateException("Log not found"))
assertEquals(log.config.overriddenConfigs.size, 1) // Verify topic-level config still survives

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As before, it may be good to check the actual config expected. It would also be useful to verify the behaviour after updating and removing broker-level MinInSyncReplicasProp.

}

@Test
def testDefaultTopicConfig(): Unit = {
val (producerThread, consumerThread) = startProduceConsume(retries = 0)
Expand Down Expand Up @@ -774,7 +811,7 @@ class DynamicBrokerReconfigurationTest extends ZooKeeperTestHarness with SaslSet
val partitions = (0 until numPartitions).map(i => new TopicPartition(topic, i)).filter { tp =>
zkClient.getLeaderForPartition(tp).contains(leaderId)
}
assertTrue(s"Partitons not found with leader $leaderId", partitions.nonEmpty)
assertTrue(s"Partitions not found with leader $leaderId", partitions.nonEmpty)
partitions.foreach { tp =>
(1 to 2).foreach { i =>
val replicaFetcherManager = servers(i).replicaManager.replicaFetcherManager
Expand Down