private void clearSubscription() {
        if (subscriptions.hasAutoAssignedPartitions()) {
            subscriptions.assignFromSubscribed(Collections.emptySet());
        }
        updateAssignment(Collections.emptySet());
        clearPendingAssignmentsAndLocalNamesCache();
    }
Clear the assigned partitions in the member subscription, pending assignments and metadata cache.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareMembershipManager.java