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-15039: Reduce logging level to trace in PartitionChangeBuilder.… #13780

Merged
merged 4 commits into from
May 31, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,24 @@ private boolean isValidNewLeader(int replica) {
private void tryElection(PartitionChangeRecord record) {
ElectionResult electionResult = electLeader();
if (electionResult.node != partition.leader) {
log.debug(
"Setting new leader for topicId {}, partition {} to {} using {} election",
topicId,
partitionId,
electionResult.node,
electionResult.unclean ? "an unclean" : "a clean"
);
// generating log messages for partition elections can get expensive on large clusters,
// so only log clean elections at TRACE level;
// log unclean elections at WARN level since doing so can lead to data loss.
if (electionResult.unclean) {
log.warn(
Copy link
Contributor

@hachikuji hachikuji May 31, 2023

Choose a reason for hiding this comment

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

How about INFO level? Unclean election is "expected behavior" if it is enabled or requested specifically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, sounds good. Will adjust.

"Setting new leader for topicId {}, partition {} to {} using an unclean election",
topicId,
partitionId,
electionResult.node
);
} else if (log.isTraceEnabled()) {
log.trace(
"Setting new leader for topicId {}, partition {} to {} using a clean election",
topicId,
partitionId,
electionResult.node
);
}
record.setLeader(electionResult.node);
if (electionResult.unclean) {
// If the election was unclean, we have to forcibly set the ISR to just the
Expand All @@ -239,7 +250,9 @@ private void tryElection(PartitionChangeRecord record) {
}
}
} else {
log.debug("Failed to find a new leader with current state: {}", this);
if (log.isTraceEnabled()) {
log.trace("Failed to find a new leader with current state: {}", this);
}
}
}

Expand Down