private <T> CoordinatorResult<T, CoordinatorRecord> shareGroupFenceMember(
        ShareGroup group,
        ShareGroupMember member,
        T response
    ) {
        List<CoordinatorRecord> records = new ArrayList<>();
        List<CoordinatorRecord> replayRecords = new ArrayList<>();

        replayRecords.add(newCurrentAssignmentTombstoneRecord(group.groupId(), member.memberId()));
        replayRecords.add(newTargetAssignmentTombstoneRecord(group.groupId(), member.memberId()));
        // Persist member tombstone record.
        records.add(newShareGroupMemberSubscriptionTombstoneRecord(group.groupId(), member.memberId()));

        // We update the subscription metadata without the leaving member.
        Map<String, TopicMetadata> subscriptionMetadata = group.computeSubscriptionMetadata(
            group.computeSubscribedTopicNames(member, null),
            metadataImage.topics(),
            metadataImage.cluster()
        );

        if (!subscriptionMetadata.equals(group.subscriptionMetadata())) {
            log.info("[GroupId {}] Computed new subscription metadata: {}.",
                group.groupId(), subscriptionMetadata);
            replayRecords.add(newGroupSubscriptionMetadataRecord(group.groupId(), subscriptionMetadata));
        }

        // We bump the group epoch.
        int groupEpoch = group.groupEpoch() + 1;
        records.add(newGroupEpochRecord(group.groupId(), groupEpoch, SHARE));

        cancelGroupSessionTimeout(group.groupId(), member.memberId());

        /*
         Replay generated records for share consumer as only group epoch records are persisted for
         share consumer.
        */
        replayRecords.forEach(this::replay);

        return new CoordinatorResult<>(records, response);
    }
Removes a member from a share group.

@param group       The group.
@param member      The member.

@return A list of records to be applied to the state.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java