Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-16261: updateSubscription fails if already empty subscription #15440

Merged
merged 4 commits into from Mar 1, 2024

Conversation

lucasbru
Copy link
Member

The internal SubscriptionState object keeps track of whether the assignment is user-assigned, or auto-assigned. If there are no assigned partitions, the assignment resets to NONE. If you call SubscriptionState.assignFromSubscribed in this state it fails.

This change makes sure to check SubscriptionState.hasAutoAssignedPartitions() so that assignFromSubscribed is going to be permitted.

Also, a minor refactoring to make clearing the subscription a bit easier to follow in MembershipManagerImpl.

Testing via new unit test.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@lucasbru
Copy link
Member Author

@AndrewJSchofield could you have a look, since you created the ticket? I wasn't quite sure in which sequence of events to observed the problem. The unit test emulates clearing the assignment while leave group is in progress.

Copy link
Contributor

@AndrewJSchofield AndrewJSchofield left a comment

Choose a reason for hiding this comment

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

lgtm

@cadonna
Copy link
Contributor

cadonna commented Feb 29, 2024

@lucasbru Unit tests are failing in MembershipManagerImplTest.

Copy link
Contributor

@cadonna cadonna left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @lucasbru !

Here my feedback.

As I said earlier some unit tests fail consistently.

@@ -764,6 +766,44 @@ public void testLeaveGroupWhenMemberOwnsAssignment() {
testLeaveGroupReleasesAssignmentAndResetsEpochToSendLeaveGroup(membershipManager);
}

@Test
public void testLeaveGroupWhenAssignmentEmpty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there maybe a more direct way to test the bug?
I had a hard time to understand this unit test.
Nevermind if there is no more direct way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced it by a simpler test

// Complete the callback
callbackEvent.future().complete(null);

// Completed the listener
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment does not make too much sense since the leave future is still verified to be not completed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@cadonna cadonna left a comment

Choose a reason for hiding this comment

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

Thanks @lucasbru !

LGTM!

…y empty subscription

The internal SubscriptionState object keeps track of whether the assignment is user-assigned,
or auto-assigned. If there are no assigned partitions, the assignment resets to NONE. If you
call SubscriptionState.assignFromSubscribed in this state it fails.

This change makes sure to check SubscriptionState.hasAutoAssignedPartitions() so that
assignFromSubscribed is going to be permitted.

Also a minor refactoring to make clearing the subscription a bit easier
to follow in MembershipManagerImpl.
@lucasbru lucasbru merged commit 8e1516f into apache:trunk Mar 1, 2024
1 check failed
clolov pushed a commit to clolov/kafka that referenced this pull request Apr 5, 2024
…pache#15440)

The internal SubscriptionState object keeps track of whether the assignment is user-assigned, or auto-assigned. If there are no assigned partitions, the assignment resets to NONE. If you call SubscriptionState.assignFromSubscribed in this state it fails.

This change makes sure to check SubscriptionState.hasAutoAssignedPartitions() so that assignFromSubscribed is going to be permitted.

Also, a minor refactoring to make clearing the subscription a bit easier to follow in MembershipManagerImpl.

Testing via new unit test.

Reviewers: Bruno Cadonna <cadonna@apache.org>, Andrew Schofield <aschofield@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants