Skip to content

KAFKA-21214: [3/N] Add the shares and hand out of the uniform2 assignor - #23733

Open
dajac wants to merge 2 commits into
apache:trunkfrom
dajac:uniform2-baseline-shares
Open

dajac wants to merge 2 commits into
apache:trunkfrom
dajac:uniform2-baseline-shares

Conversation

@dajac

@dajac dajac commented Oct 6, 2026

Copy link
Copy Markdown
Member

Depends on #23732: only the last commit belongs to this PR.

uniform2 decides how many partitions of every topic each member gets,
its shares, in three steps, keep, hand out and balance, and then places
the partitions. A topic with P partitions and N subscribers gives P / N
base partitions to each of them, and its P % N extra partitions to as
many distinct subscribers.

This patch adds the shares and their first two steps:

  • Shares holds the base and extra partitions of every topic, the
    members getting the extra partitions, and the sizes of the members.
    In the keep step, a member owning more than the base partitions of a
    topic keeps one of its extra partitions, the members with the
    smallest assignments first when the owners outnumber the extra
    partitions.
  • HandOut gives the extra partitions that nobody kept, one at a time,
    to subscribers without one of the topic, among the ones with the
    smallest assignments: the topics with the fewest subscribers first,
    and round robin within a cohort.
  • TestGroup builds the model, the current assignment and the shares
    of a group for the tests of the steps.

The balance step comes in a later patch.

dajac and others added 2 commits October 6, 2026 18:32
The uniform assignor balances the total number of partitions per member
but not the partitions of each topic: with homogeneous subscriptions, a
member can get all the partitions of a topic while the others get none
of them. uniform2, the next version of the uniform assignor, spreads
every topic over its subscribers. It reads the group, decides how many
partitions of every topic each member gets in three steps, keep, hand
out and balance, and then places the partitions. This stack adds it
one step at a time, and the assignor itself last.

This patch adds the model of the group that every step reads:
- `GroupModel` numbers the members in member id order and the topics in
  topic id order, so that every decision depends on the content of the
  input only. It drops the topics that do not exist, and groups the
  members with the same subscription into cohorts.
- `CurrentAssignment` reads the owner of every partition. What the
  members hold beyond that is stale: partitions of topics they do not
  subscribe to or which no longer exist, partitions beyond the
  partition count, and empty sets.
- `AssignmentTestUtils` builds groups for the tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
uniform2 decides how many partitions of every topic each member gets,
its shares, in three steps, keep, hand out and balance, and then places
the partitions. A topic with P partitions and N subscribers gives P / N
base partitions to each of them, and its P % N extra partitions to as
many distinct subscribers.

This patch adds the shares and their first two steps:
- `Shares` holds the base and extra partitions of every topic, the
  members getting the extra partitions, and the sizes of the members.
  In the keep step, a member owning more than the base partitions of a
  topic keeps one of its extra partitions, the members with the
  smallest assignments first when the owners outnumber the extra
  partitions.
- `HandOut` gives the extra partitions that nobody kept, one at a time,
  to subscribers without one of the topic, among the ones with the
  smallest assignments: the topics with the fewest subscribers first,
  and round robin within a cohort.
- `TestGroup` builds the model, the current assignment and the shares
  of a group for the tests of the steps.

The balance step comes in a later patch.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

1 participant