Skip to content

KAFKA-21309: Handle Metadata responses without topic names - #23870

Open
jpalmerr wants to merge 3 commits into
apache:trunkfrom
jpalmerr:KAFKA-21309-repro
Open

jpalmerr wants to merge 3 commits into
apache:trunkfrom
jpalmerr:KAFKA-21309-repro

Conversation

@jpalmerr

@jpalmerr jpalmerr commented Oct 19, 2026 •

Copy link
Copy Markdown

KAFKA-21309

A consumer subscribed with SubscriptionPattern requests metadata by
topic ID. When an assigned topic is deleted, or the client may not
describe it, the broker answers its ID with an error and no topic name,
as the schema allows. The client did not handle the null topic name row.

This fix

  1. MetadataResponse skips error rows without a name, as opposed to
    throwing IllegalStateException.
  2. Now that a null name can reach the response handler, it skips the
    row. On a retriable error (e.g. UNKNOWN_TOPIC_ID) it also requests a
    metadata update, else (e.g. TOPIC_AUTHORIZATION_FAILED) it leaves the
    Fetch response to raise TopicAuthorizationException

Once metadata updates resume, reconciliation revokes the deleted topic's
partitions and resolves newly assigned topics.

@github-actions github-actions Bot added tests Test fixes (including flaky tests) clients small Small PRs triage PRs from the community labels Oct 19, 2026
@jpalmerr

Copy link
Copy Markdown
Author

@dajac @lianetm hi! heres the reproduction as a failing unit test. I've got a script to observe the full behaviour against a real broker, including the consumer never picking up a new topic afterwards, comparing 4.0.0 with 4.1.0+.

gist with script

@jpalmerr jpalmerr changed the title KAFKA-21309: Reproduce IllegalStateException on Metadata response for a deleted topic KAFKA-21309: Handle Metadata responses without topic names Oct 23, 2026
@github-actions github-actions Bot added consumer and removed small Small PRs labels Oct 23, 2026
@jpalmerr

Copy link
Copy Markdown
Author

This PR now has the fix.

With the reproducer from the gist, a consumer on this branch kept updating metadata after the assigned topic was deleted, consumed the newly created matching topic, and sent no excess heartbeats.

@jpalmerr
jpalmerr marked this pull request as ready for review October 23, 2026 19:02
@lianetm lianetm added ci-approved and removed triage PRs from the community labels Oct 23, 2026
@lianetm
lianetm self-requested a review October 23, 2026 19:07
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved clients consumer tests Test fixes (including flaky tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants