Skip to content

Commit 5924673

Browse files
committed
KAFKA-19596: Improve visibility when topic auto-creation fails
Log a warning for each topic that failed to be created as a result of an automatic creation. Previously, at the default log level, you could only see logs that the broker was attempting to autocreate topics. If the creation failed it was logged at debug. This makes it more visible. Signed-off-by: Robert Young <[email protected]>
1 parent dbf3808 commit 5924673

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

core/src/main/scala/kafka/server/AutoTopicCreationManager.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import org.apache.kafka.common.message.CreateTopicsRequestData
2929
import org.apache.kafka.common.message.CreateTopicsRequestData.{CreatableTopic, CreatableTopicConfig, CreatableTopicConfigCollection}
3030
import org.apache.kafka.common.message.MetadataResponseData.MetadataResponseTopic
3131
import org.apache.kafka.common.protocol.{ApiKeys, Errors}
32-
import org.apache.kafka.common.requests.{CreateTopicsRequest, RequestContext, RequestHeader}
32+
import org.apache.kafka.common.requests.{CreateTopicsRequest, CreateTopicsResponse, RequestContext, RequestHeader}
3333
import org.apache.kafka.coordinator.group.GroupCoordinator
3434
import org.apache.kafka.coordinator.share.ShareCoordinator
3535
import org.apache.kafka.coordinator.transaction.TransactionLogConfig
@@ -138,6 +138,19 @@ class DefaultAutoTopicCreationManager(
138138
} else if (response.versionMismatch() != null) {
139139
warn(s"Auto topic creation failed for ${creatableTopics.keys} with invalid version exception")
140140
} else {
141+
if (response.hasResponse) {
142+
response.responseBody() match {
143+
case createTopicsResponse: CreateTopicsResponse =>
144+
createTopicsResponse.data().topics().forEach(topicResult => {
145+
val error = Errors.forCode(topicResult.errorCode)
146+
if (error != Errors.NONE) {
147+
warn(s"Auto topic creation failed for ${topicResult.name} with error '${error.name}': ${topicResult.errorMessage}")
148+
}
149+
})
150+
case other =>
151+
warn(s"Auto topic creation request received unexpected response type: ${other.getClass.getSimpleName}")
152+
}
153+
}
141154
debug(s"Auto topic creation completed for ${creatableTopics.keys} with response ${response.responseBody}.")
142155
}
143156
}

0 commit comments

Comments
 (0)