-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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-5822: Consistent log formatting of topic partitions #3778
Conversation
retest this please |
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.
Thanks for the PR. Looks good overall, just a few comments (one of them important).
@@ -69,7 +69,7 @@ class Partition(val topic: String, | |||
* In addition to the leader, the controller can also send the epoch of the controller that elected the leader for | |||
* each partition. */ | |||
private var controllerEpoch: Int = KafkaController.InitialControllerEpoch - 1 | |||
this.logIdent = "Partition [%s,%d] on broker %d: ".format(topic, partitionId, localBrokerId) | |||
this.logIdent = s"Partition $topicPartition on broker $localBrokerId: " |
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.
Shall we use the convention we've been using for LogContext
? That is [Foo key=value]
.
@@ -37,5 +37,5 @@ case class TopicAndPartition(topic: String, partition: Int) { | |||
|
|||
def asTopicPartition = new TopicPartition(topic, partition) | |||
|
|||
override def toString = "[%s,%d]".format(topic, partition) | |||
override def toString(): String = s"$topic-$partition" |
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.
Do we need the ()
here?
.format(controllerId, controller.epoch, replicaId, topic, partition, currState, targetState), t) | ||
stateChangeLogger.error(("Controller %d epoch %d initiated state change of replica %d for partition " + | ||
"%s from %s to %s failed") | ||
.format(controllerId, controller.epoch, replicaId, topicAndPartition, currState, targetState), t) |
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.
Maybe you want to change this to use string interpolation as well?
updatePartitionsWithError(topicPartition) | ||
case e: KafkaStorageException => | ||
logger.error(s"Error while processing data for partition $topicPartition", e) | ||
updatePartitionsWithError(topicPartition) | ||
case e: Throwable => | ||
throw new KafkaException("error processing data for partition [%s,%d] offset %d" | ||
.format(topic, partitionId, currentPartitionFetchState.fetchOffset), e) | ||
throw new KafkaException(s"error processing data for partition $topicPartition " + |
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.
Capitalise?
} catch { | ||
case e: FatalExitError => throw e | ||
case e: Throwable => | ||
error("Error getting offset for partition [%s,%d] to broker %d".format(topic, partitionId, sourceBroker.id), e) | ||
error(s"Error getting offset for partition $topicPartition to broker ${sourceBroker.id}") |
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.
Is it intentional to drop the e
from the log?
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.
Good catch.
val dirOpt = getLogDir(new TopicPartition(partition.topic, partition.partitionId)) | ||
"controller %d epoch %d for partition %s since the replica for the partition is offline due to disk error %s") | ||
.format(localBrokerId, correlationId, controllerId, partitionStateInfo.basePartitionState.controllerEpoch, | ||
partition.topicPartition, e)) |
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.
String interpolation here too?
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.
ugh. you knew that mentioning this would force me to change all the others too
a40373c
to
8ef7730
Compare
8ef7730
to
a4fa5c3
Compare
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.
Thanks for the PR, LGTM. I'll make the 3 trivial fixes below before merging to trunk.
"%d epoch %d with correlation id %d for partition %s") | ||
.format(localBrokerId, controllerId, epoch, correlationId, partition.topicPartition)) | ||
stateChangeLogger.trace("Stopped fetchers as part of become-leader request from controller " + | ||
s"$controllerId epoch $epoch with correlation id $correlationId for partition ${partition.topicPartition}" + |
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.
Space missing here before (last
. Will fix before merging.
stateChangeLogger.error(s"Skipped the become-leader state change with correlation id $correlationId from " + | ||
s"controller $controllerId epoch $epoch for partition ${partition.topicPartition} " + | ||
s"(last update controller epoch ${partitionStateInfo.basePartitionState.controllerEpoch}) since " + | ||
s"the replica for the partition is offline due to disk error in $e") |
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.
in
before e
probably unintentional.
stateChangeLogger.info("Skipped the become-follower state change after marking its partition as " + | ||
s"follower with correlation id $correlationId from controller $controllerId epoch $epoch " + | ||
s"for partition ${partition.topicPartition} (last update " + | ||
s"controller epoch ${partitionStateInfo.basePartitionState.controllerEpoch}), " + |
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.
Removing the comma since it doesn't seem to flow right given that the next word is since
.
No description provided.