squah-confluent commented on code in PR #24386:
URL: https://github.com/apache/kafka/pull/24386#discussion_r4696108793
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
Review Comment:
I think there are two aspects to the bug:
1. that we delete an empty consumer or streams group for a rejected classic
JoinGroup and
2. that we diverged between in-memory state and the log at all
We are addressing 1 but not 2, which is a deeper systemic issue to do with
the way the code is structured.
For 2, we must always add a record to the `records` accumulator whenever we
make an in-memory change, which I believe we did. Then the gap is that we
discard the accumulated records so far despite the in-memory changes. So should
we not return `EMPTY_RESULT` for robustness? (perhaps in a separate PR)
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -7772,11 +7772,14 @@ public CoordinatorResult<Boolean, CoordinatorRecord>
classicGroupJoin(
// The empty consumer groups should be converted to classic
groups in classicGroupJoinToClassicGroup.
return
cleanupNotNeeded(classicGroupJoinToConsumerGroup((ConsumerGroup) group,
context, request, responseFuture));
} else if (group.type() == STREAMS && group.isEmpty()) {
- if (!topologyCleanupHandled && ((StreamsGroup)
group).mayHaveTopologyDescription()) {
+ if (!topologyCleanupHandled
+ && UNKNOWN_MEMBER_ID.equals(request.memberId())
+ && ((StreamsGroup) group).mayHaveTopologyDescription()) {
// A classic join converts this empty streams group to
classic and deletes its streams
// metadata. If the topology-description plugin (KIP-1331)
may still hold a topology for the
// group, that data would be orphaned. So change nothing
and return TRUE. The caller deletes
// the topology from the plugin, then calls again with
topologyCleanupHandled = true to convert.
+ // A join with a known member id keeps the group, so it
needs no cleanup.
Review Comment:
nit: This comment belongs on the new condition except it's too far away and
reads in isolation. Perhaps we should move this entire comment block up above
the `if`.
##########
core/src/test/scala/unit/kafka/server/ConsumerProtocolMigrationTest.scala:
##########
@@ -163,6 +163,69 @@ class ConsumerProtocolMigrationTest(cluster:
ClusterInstance) extends GroupCoord
testDowngradeFromEmptyConsumerToClassicGroup()
}
+ @ClusterTest
+ def testClassicJoinWithKnownMemberIdToEmptyConsumerGroup(): Unit = {
Review Comment:
naming: We already have
`testClassicMemberJoinToConsumerGroupWithDisabledMigrationPolicy`. Can we try
to rename these to be consistent?
eg.
`testClassicJoinTo(Empty)?ConsumerGroup(WithDisabledMigrationPolicy|WithKnownMemberId)`.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -7834,10 +7837,15 @@ CoordinatorResult<Void, CoordinatorRecord>
classicGroupJoinToClassicGroup(
// is specified but the group does not exist, the request is rejected
with
// UNKNOWN_MEMBER_ID.
ClassicGroup group;
- if (maybeDeleteEmptyConsumerGroup(groupId, records)) {
- log.info("[GroupId {}] Converted the empty consumer group to a
classic group.", groupId);
- } else if (maybeDeleteEmptyStreamsGroup(groupId, records)) {
- log.info("[GroupId {}] Converted the empty streams group to a
classic group.", groupId);
+ // Only a request with an unknown member id can create the classic
group below, so only
+ // such a request deletes an empty consumer or streams group to make
room for it. A request
+ // with a known member id is rejected with UNKNOWN_MEMBER_ID and keeps
the group.
Review Comment:
I thought a "known member id" was one that was already in the group. Can we
call it something else? "non-empty member id" or just "member id" (as opposed
to empty member id) both work for me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]