mirror of https://github.com/apache/kafka.git
MINOR: Change ordering of checks to prevent log spam on metadata updates (#13447)
On startup, we always update the metadata. The topic ID also goes from null to defined. Move the epoch is null check to before the topic ID check to prevent log spam. Reviewers: David Jacot <djacot@confluent.io>, Jason Gustafson <jason@confluent.io>
This commit is contained in:
parent
887d05559f
commit
6d9d65e666
|
|
@ -394,7 +394,13 @@ public class Metadata implements Closeable {
|
||||||
if (hasReliableLeaderEpoch && partitionMetadata.leaderEpoch.isPresent()) {
|
if (hasReliableLeaderEpoch && partitionMetadata.leaderEpoch.isPresent()) {
|
||||||
int newEpoch = partitionMetadata.leaderEpoch.get();
|
int newEpoch = partitionMetadata.leaderEpoch.get();
|
||||||
Integer currentEpoch = lastSeenLeaderEpochs.get(tp);
|
Integer currentEpoch = lastSeenLeaderEpochs.get(tp);
|
||||||
if (topicId != null && !topicId.equals(oldTopicId)) {
|
if (currentEpoch == null) {
|
||||||
|
// We have no previous info, so we can just insert the new epoch info
|
||||||
|
log.debug("Setting the last seen epoch of partition {} to {} since the last known epoch was undefined.",
|
||||||
|
tp, newEpoch);
|
||||||
|
lastSeenLeaderEpochs.put(tp, newEpoch);
|
||||||
|
return Optional.of(partitionMetadata);
|
||||||
|
} else if (topicId != null && !topicId.equals(oldTopicId)) {
|
||||||
// If the new topic ID is valid and different from the last seen topic ID, update the metadata.
|
// If the new topic ID is valid and different from the last seen topic ID, update the metadata.
|
||||||
// Between the time that a topic is deleted and re-created, the client may lose track of the
|
// Between the time that a topic is deleted and re-created, the client may lose track of the
|
||||||
// corresponding topicId (i.e. `oldTopicId` will be null). In this case, when we discover the new
|
// corresponding topicId (i.e. `oldTopicId` will be null). In this case, when we discover the new
|
||||||
|
|
@ -403,7 +409,7 @@ public class Metadata implements Closeable {
|
||||||
tp, newEpoch, oldTopicId, topicId);
|
tp, newEpoch, oldTopicId, topicId);
|
||||||
lastSeenLeaderEpochs.put(tp, newEpoch);
|
lastSeenLeaderEpochs.put(tp, newEpoch);
|
||||||
return Optional.of(partitionMetadata);
|
return Optional.of(partitionMetadata);
|
||||||
} else if (currentEpoch == null || newEpoch >= currentEpoch) {
|
} else if (newEpoch >= currentEpoch) {
|
||||||
// If the received leader epoch is at least the same as the previous one, update the metadata
|
// If the received leader epoch is at least the same as the previous one, update the metadata
|
||||||
log.debug("Updating last seen epoch for partition {} from {} to epoch {} from new metadata", tp, currentEpoch, newEpoch);
|
log.debug("Updating last seen epoch for partition {} from {} to epoch {} from new metadata", tp, currentEpoch, newEpoch);
|
||||||
lastSeenLeaderEpochs.put(tp, newEpoch);
|
lastSeenLeaderEpochs.put(tp, newEpoch);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue