New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-7906: Improve logging for failed leader elections #8176
base: trunk
Are you sure you want to change the base?
Changes from 4 commits
794327b
cb25ec3
0a5f651
25f6a30
d2e1ef2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,7 +131,7 @@ class ZkPartitionStateMachine(config: KafkaConfig, | |
extends PartitionStateMachine(controllerContext) { | ||
|
||
private val controllerId = config.brokerId | ||
this.logIdent = s"[PartitionStateMachine controllerId=$controllerId] " | ||
this.logIdent = s"[PartitionStateMachine controllerId=$controllerId controllerEpoch=${controllerContext.epoch}] " | ||
|
||
/** | ||
* Try to change the state of the given partitions to the given targetState, using the given | ||
|
@@ -337,7 +337,18 @@ class ZkPartitionStateMachine(config: KafkaConfig, | |
|
||
finished.foreach { | ||
case (partition, Left(e)) => | ||
logFailedStateChange(partition, partitionState(partition), OnlinePartition, e) | ||
// Extract failure message, if present, to append to error log. | ||
val reasonMsg = if (e.isInstanceOf[StateChangeFailedException]) { | ||
s", reason: ${e.getMessage}" | ||
} else { | ||
"" | ||
} | ||
val failMsg = s"Controller failed to change state for partition $partition from ${partitionState(partition)} to $OnlinePartition" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: since the log identity already starts with "Controller," I think we can leave it out and start from "Failed." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
if (e.isInstanceOf[StateChangeFailedException]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, did the equivalent e match {
case _:StateChangeFailedException => ...
case _ => ...
} |
||
logger.error(s"$failMsg: $reasonMsg") | ||
} else { | ||
logger.error(s"$failMsg: unknown exception: ", e) | ||
} | ||
case (_, Right(_)) => // Ignore; success so no need to log failed state change | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be simpler to move this into the check below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done