Skip to content

KAFKA-20790: Follow up, avoid translation of assignmentconfig and make the output type unmodifiable - #23165

Open
gabriellefu wants to merge 8 commits into
apache:trunkfrom
gabriellefu:avoid_translate
Open

KAFKA-20790: Follow up, avoid translation of assignmentconfig and make the output type unmodifiable#23165
gabriellefu wants to merge 8 commits into
apache:trunkfrom
gabriellefu:avoid_translate

Conversation

@gabriellefu

@gabriellefu gabriellefu commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

change: guard the output of assignor to make it unmofiable only
convert assignmentimpl when it's neccessary

Reviewers: Chia-Ping Tsai chia7712@gmail.com, Matthias J. Sax
matthias@confluent.io

@github-actions github-actions Bot added triage PRs from the community group-coordinator labels Aug 14, 2026
final int numStandbyReplicas = groupConfig.flatMap(GroupConfig::streamsNumStandbyReplicas)
.orElse(config.streamsGroupNumStandbyReplicas());
final List<String> rackAwareAssignmentTags = groupConfig.flatMap(GroupConfig::streamsRackAwareAssignmentTags)
.orElse(config.streamsGroupRackAwareAssignmentTags());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the GroupConfig::streamsRackAwareAssignmentTags and config.streamsGroupRackAwareAssignmentTags() are both the trim() + split("\s*,\s*", -1) version, so no guard for empty space needed in downstreams

String numStandbyReplicas = configs.getOrDefault(NUM_STANDBY_REPLICAS_CONFIG,
Integer.toString(GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT));
String rackAwareAssignmentTags = configs.getOrDefault(RACK_AWARE_ASSIGNMENT_TAGS_CONFIG,
GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

modified as @chia7712 suggested

Map<String, MemberAssignment> members
) {
this.members = Objects.requireNonNull(members);
this.members = Map.copyOf(members);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

follow up of @chia7712 comment

@github-actions github-actions Bot removed the triage PRs from the community label Aug 15, 2026
@AndrewJSchofield AndrewJSchofield changed the title KAFKA-20790: Follow up, avoid tranlation of assignmentconfig and make the output type unmodifiable KAFKA-20790: Follow up, avoid translation of assignmentconfig and make the output type unmodifiable Aug 16, 2026

@chia7712 chia7712 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.

@gabriellefu thanks for this patch.


/**
* @return The member assignments keyed by member ID.
* @return The member assignments keyed by member ID. The map is unmodifiable.

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.

It appears the original logic aligns with org.apache.kafka.coordinator.group.api.assignor.GroupAssignment. They are used by different assignor interfaces, so having different "decorations" should be fine.

@mjsax mjsax 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 for the improvements. Made a pass.

GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT);
return new AssignmentConfigsImpl(
Integer.parseInt(configs.get(NUM_STANDBY_REPLICAS_CONFIG)),
Integer.parseInt(numStandbyReplicas),

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.

If standby replicas are not set, we first convert the default int into String above, to just parse it back to int again. Should we set this up differently:

String numStandbyReplicasConfig = configs.get(NUM_STANDBY_REPLICAS_CONFIG);
int numStandbyReplicas = numStandbyReplicasConfig != null ? Integer.parseInt(numStandbyReplicasConfig) : GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT;

Or something like this? And pass int numStandbyReplicas here directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

got it, thanks

long metadataHash,
int validatedTopologyEpoch,
Map<String, String> assignmentConfigs,
Optional<AssignmentConfigsImpl> assignmentConfigs,

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.

Why is this an Optional ? Same question elsewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

AssignmentConfigs in StreamsGroupMetadataValue.json defaults to null, so if lastassignmentconfig is never recorded, it's gonna be null

// them unrecorded. The next heartbeat then compares the effective configs against the defaults, so it
// only rebalances the group if any effective config differs from its default.
if (value.lastAssignmentConfigs() == null || value.lastAssignmentConfigs().isEmpty()) {
streamsGroup.setLastAssignmentConfigs(Optional.empty());

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.

Instead of having Optional type wired thought many classes, could we not just set a "default" object here right away?

Would be good to get input from @squah-confluent or @dajac on this one, to not break anything by accident, and keep the code structure consistent across group types.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I'd like to hear their take on this too before changing it.

@mjsax mjsax added the streams label Aug 20, 2026
@gabriellefu

Copy link
Copy Markdown
Contributor Author

I have updated base on comments, thanks @chia7712 @mjsax

@gabriellefu
gabriellefu requested review from chia7712 and mjsax August 21, 2026 21:34
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.

3 participants