Skip to content

KAFKA-20885: Fix IQ metadata for source topics with fewer partitions - #23050

Merged
mjsax merged 2 commits into
apache:trunkfrom
mjsax:kafka-20885-fix-streams-iq-metadata
Aug 4, 2026
Merged

KAFKA-20885: Fix IQ metadata for source topics with fewer partitions#23050
mjsax merged 2 commits into
apache:trunkfrom
mjsax:kafka-20885-fix-streams-iq-metadata

Conversation

@mjsax

@mjsax mjsax commented Aug 3, 2026

Copy link
Copy Markdown
Member

EndpointToPartitionsManager clamped the partitions it reports for a
member by comparing the topic's partition count against the number of
tasks the member owns, and then keeping the lowest task IDs. That is
only correct when a single member owns the whole subtopology.

A subtopology has as many tasks as its source topic with the most
partitions, so a smaller source topic has no partition for the higher
task IDs. When a member owns a "non-prefix" task set, the size-based
check does not fire and the task IDs are reported verbatim as partitions
of that smaller topic, advertising partitions that do not exist.

Filter the task IDs by value, and omit a source topic entirely when none
of the member's tasks map to one of its partitions. This mirrors
PartitionGrouper#partitionGroups, which computes the same mapping for
the classic protocol.

Reviewers: Bill Bejeck bbejeck@apache.org

@mjsax
mjsax force-pushed the kafka-20885-fix-streams-iq-metadata branch from cc75170 to 62df680 Compare August 3, 2026 00:28
EndpointToPartitionsManager clamped the partitions it reports for a
member by comparing the topic's partition count against the *number* of
tasks the member owns, and then keeping the lowest task IDs. That is
only correct when a single member owns the whole subtopology.

A subtopology has as many tasks as its source topic with the most
partitions, so a smaller source topic has no partition for the higher
task IDs. When a member owns a "non-prefix" task set, the size-based check
does not fire and the task IDs are reported verbatim as partitions of
that smaller topic, advertising partitions that do not exist.

Filter the task IDs by value, and omit a source topic entirely when none
of the member's tasks map to one of its partitions. This mirrors
PartitionGrouper#partitionGroups, which computes the same mapping for
the classic protocol.
@mjsax
mjsax force-pushed the kafka-20885-fix-streams-iq-metadata branch from 62df680 to a10822a Compare August 3, 2026 00:38
@mjsax mjsax added the streams label Aug 3, 2026

@bbejeck bbejeck left a comment

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.

Thanks @mjsax overall lgtm with one minor comment

// fewer partitions therefore has no partition for the higher task IDs, mirroring the client-side
// grouping in PartitionGrouper#partitionGroups.
List<Integer> partitions = taskSet.stream()
.filter(taskId -> taskId < numPartitionsForTopic)

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.

nit: maybe change taskId -> partitionId

@bbejeck bbejeck left a comment

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.

Thanks @mjsax LGTM

@mjsax
mjsax merged commit a6fef7f into apache:trunk Aug 4, 2026
22 checks passed
@mjsax
mjsax deleted the kafka-20885-fix-streams-iq-metadata branch August 4, 2026 01:35
mjsax added a commit that referenced this pull request Aug 4, 2026
…23050)

EndpointToPartitionsManager clamped the partitions it reports for a
member by comparing the topic's partition count against the *number* of
tasks the member owns, and then keeping the lowest task IDs. That is
only correct when a single member owns the whole subtopology.

A subtopology has as many tasks as its source topic with the most
partitions, so a smaller source topic has no partition for the higher
task IDs. When a member owns a "non-prefix" task set, the size-based
check does not fire and the task IDs are reported verbatim as partitions
of that smaller topic, advertising partitions that do not exist.

Filter the task IDs by value, and omit a source topic entirely when none
of the member's tasks map to one of its partitions. This mirrors
PartitionGrouper#partitionGroups, which computes the same mapping for
the classic protocol.

Reviewers: Bill Bejeck <bbejeck@apache.org>
mjsax added a commit that referenced this pull request Aug 4, 2026
…23050)

EndpointToPartitionsManager clamped the partitions it reports for a
member by comparing the topic's partition count against the *number* of
tasks the member owns, and then keeping the lowest task IDs. That is
only correct when a single member owns the whole subtopology.

A subtopology has as many tasks as its source topic with the most
partitions, so a smaller source topic has no partition for the higher
task IDs. When a member owns a "non-prefix" task set, the size-based
check does not fire and the task IDs are reported verbatim as partitions
of that smaller topic, advertising partitions that do not exist.

Filter the task IDs by value, and omit a source topic entirely when none
of the member's tasks map to one of its partitions. This mirrors
PartitionGrouper#partitionGroups, which computes the same mapping for
the classic protocol.

Reviewers: Bill Bejeck <bbejeck@apache.org>
@mjsax

mjsax commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Merged to trunk and cherry-picked to 4.3 and 4.2 branches.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants