Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

hachikuji
Copy link

No description provided.

@ijuma
Copy link
Contributor

ijuma commented Sep 14, 2017

retest this please

Copy link
Contributor

@ijuma ijuma left a 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: "
Copy link
Contributor

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"
Copy link
Contributor

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)
Copy link
Contributor

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 " +
Copy link
Contributor

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}")
Copy link
Contributor

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?

Copy link
Author

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))
Copy link
Contributor

Choose a reason for hiding this comment

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

String interpolation here too?

Copy link
Author

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

Copy link
Contributor

@ijuma ijuma left a 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}" +
Copy link
Contributor

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")
Copy link
Contributor

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}), " +
Copy link
Contributor

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.

@asfgit asfgit closed this in f6f56a6 Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants