Skip to content

KAFKA-20566: Improve logging in share coordinator#22257

Open
AndrewJSchofield wants to merge 2 commits into
apache:trunkfrom
AndrewJSchofield:KAFKA-20566
Open

KAFKA-20566: Improve logging in share coordinator#22257
AndrewJSchofield wants to merge 2 commits into
apache:trunkfrom
AndrewJSchofield:KAFKA-20566

Conversation

@AndrewJSchofield
Copy link
Copy Markdown
Member

@AndrewJSchofield AndrewJSchofield commented May 11, 2026

This PR just improves the logging for situations in which the metadata
image in the share coordinator does not contain an expected topic ID. We
see this log line in some situations but because there are 5 instances
with identical text, it's not possible to tell from the log alone which
one is responsible.

Reviewers: Chia-Ping Tsai chia7712@gmail.com, Sushant Mahajan
smahajan@confluent.io, PoAn Yang payang@apache.org

@github-actions github-actions Bot added KIP-932 Queues for Kafka small Small PRs labels May 11, 2026
if (topicMetadataOp.isEmpty() ||
topicMetadataOp.get().partitionCount() <= partitionId) {
log.error("Topic/TopicPartition not found in metadata image.");
log.error("Topic or partition not found in metadata image when initializing: {}:null-{}.", topicId, partitionId);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should try our best to resolve the topic name here?

            log.error("Topic or partition not found in metadata image when initializing: {}:{}-{}.", topicId,
                topicMetadataOp.map(CoordinatorMetadataImage.TopicMetadata::name).orElse("null"), partitionId);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

@AndrewJSchofield AndrewJSchofield requested a review from chia7712 May 14, 2026 10:03
topicMetadataOp.get().partitionCount() <= partitionId) {
log.error("Topic/TopicPartition not found in metadata image.");
log.error("Topic or partition not found in metadata image when writing: {}:{}-{}.", topicId,
topicMetadataOp.map(CoordinatorMetadataImage.TopicMetadata::name).orElse("null"), partitionId);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lets encapsulate this in a private method for readability

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've taken a look at this and I don't think it helps. If I just make the log.error line a private method, it probably harms the readability because it's a trivial method and I can't see what it does without going to the method.

If I instead take the entire if block, that is also tricky because the construction of the error response is operation-dependent.

So I prefer to leave as is in this case.

Copy link
Copy Markdown
Collaborator

@smjn smjn 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 changes, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

KIP-932 Queues for Kafka small Small PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants